/* Same font files and weights as the TradeCheck site (newTradecheck/app/assets/css/main.css):
   Yekan Bakh for Persian, Roboto 400/500 for latin text and numbers. */
@font-face { font-family: "Yekan Bakh"; font-weight: 400; font-display: swap; src: url("fonts/YekanBakh-Regular.woff2") format("woff2"); }
@font-face { font-family: "Yekan Bakh"; font-weight: 600; font-display: swap; src: url("fonts/YekanBakh-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Yekan Bakh"; font-weight: 700; font-display: swap; src: url("fonts/YekanBakh-Bold.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-weight: 400; font-display: swap; src: url("fonts/roboto-v49-latin-regular.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-weight: 500; font-display: swap; src: url("fonts/Roboto-Medium.woff2") format("woff2"); }

/* TradeCheck dark palette (newTradecheck/app/assets/css/main.css) */
:root {
  --bg: #0E0F10;
  --surface: #131313;
  --surface-2: #141920;
  --surface-3: #1B1F26;
  --border: #2B323D;
  --text: #F4F5F6;
  --muted: #8B95A3;
  --primary: #4A8FFD;
  --primary-2: #1C56AD;
  --up: #22C55E;
  --down: #EF4444;
  --teal: #54D2D7;
  --warn: #F5A524;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: "Yekan Bakh", "Roboto", Tahoma, sans-serif;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.up { color: var(--up); }
.down { color: var(--down); }
.accent { color: var(--primary); }

#app { position: relative; height: 100%; max-width: 560px; margin: 0 auto; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 14px; color: #fff; font-weight: 700; font-size: 16px;
  padding: 14px 12px; transition: transform .08s, filter .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; }
.btn-lg { width: 100%; padding: 16px; font-size: 18px; }
.btn-primary { background: linear-gradient(180deg, var(--primary), var(--primary-2)); box-shadow: 0 8px 24px -10px var(--primary); }
.btn-ghost { background: var(--surface-3); border: 1px solid var(--border); }
.btn-up { background: linear-gradient(180deg, #2BD46A, #16A34A); box-shadow: 0 8px 22px -12px var(--up); }
.btn-down { background: linear-gradient(180deg, #F25555, #DC2626); box-shadow: 0 8px 22px -12px var(--down); }
.btn-close {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-3); border: 1px solid var(--border); font-size: 17px; padding: 14px 18px;
}
.pos-pnl { direction: ltr; font-size: 20px; font-weight: 700; }
.icon-btn { background: var(--surface-3); border: 1px solid var(--border); color: var(--text); border-radius: 10px; width: 36px; height: 36px; font-size: 16px; }

/* ---------- intro ---------- */
#screen-intro, #screen-result {
  align-items: center; justify-content: center; padding: 20px 16px;
  background:
    radial-gradient(600px 320px at 50% -10%, rgba(74,143,253,.28), transparent 70%),
    radial-gradient(500px 300px at 50% 120%, rgba(84,210,215,.12), transparent 70%),
    var(--bg);
}
.intro-card, .result-card {
  width: 100%; max-width: 420px; text-align: center;
  background: rgba(20,25,32,.75); border: 1px solid var(--border); border-radius: 22px;
  padding: 26px 20px 20px; backdrop-filter: blur(8px);
}
.brand-logo { display: block; height: 44px; width: auto; margin: 4px auto 6px; filter: drop-shadow(0 6px 18px rgba(74,143,253,.35)); }
.result-brand { display: block; height: 20px; width: auto; margin: 0 auto 8px; opacity: .85; }
h1 { font-size: 26px; font-weight: 700; margin: 10px 0 6px; }
.lead { color: #C9D1DC; line-height: 1.9; margin: 0 0 14px; font-size: 15px; }
.rules { list-style: none; padding: 0; margin: 0 0 18px; text-align: right; }
.rules li {
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px;
  padding: 9px 12px; margin-bottom: 7px; font-size: 14px; color: #D6DCE4;
}
#intro-best { margin-top: 12px; min-height: 18px; }

/* ---------- game ---------- */
#screen-game { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
.topbar { display: flex; align-items: center; gap: 10px; }
.sym { display: flex; flex-direction: column; }
.sym-name { font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; font-size: 17px; direction: ltr; text-align: right; }
.tf { font-size: 11px; color: var(--muted); }
.price-box { margin-inline-start: auto; display: flex; flex-direction: column; align-items: flex-start; direction: ltr; }
.price { font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; font-size: 20px; }
.chg { font-size: 12px; font-weight: 700; }

.timer { height: 5px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
#timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal), var(--primary)); transform-origin: right; transition: background .3s; }
#timer-bar.hurry { background: linear-gradient(90deg, var(--warn), var(--down)); }

.stats { display: grid; grid-template-columns: 1fr 1fr .6fr; gap: 6px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px 10px; display: flex; flex-direction: column;
}
.stat .label { font-size: 11px; color: var(--muted); }
.stat .val { font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; font-size: 16px; direction: ltr; text-align: right; }

.chart-wrap {
  position: relative; flex: 1; min-height: 180px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
}
#chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.news {
  position: absolute; top: 8px; right: 8px; left: 72px;
  background: rgba(14,15,16,.92); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; font-size: 13.5px; line-height: 1.7;
  transform: translateY(-140%); transition: transform .35s cubic-bezier(.2,.9,.3,1.2);
  pointer-events: none;
}
.news.show { transform: translateY(0); }
.news .tag { font-weight: 700; margin-left: 6px; }
.news.bull { border-color: rgba(34,197,94,.6); }
.news.bear { border-color: rgba(239,68,68,.6); }

.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, 0);
  font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; font-size: 34px; direction: ltr;
  text-shadow: 0 4px 20px rgba(0,0,0,.6); animation: floatUp 1.4s ease-out forwards; white-space: nowrap;
}
.floater.liq { font-family: "Yekan Bakh", sans-serif; font-size: 30px; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(.7); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1); }
}
.spark { position: absolute; width: 7px; height: 7px; border-radius: 2px; animation: spark 1s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) rotate(260deg); opacity: 0; } }
.shake { animation: shake .45s; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }

.controls { display: flex; flex-direction: column; gap: 8px; }
.seg-row { display: grid; grid-template-columns: 1.25fr 1fr; gap: 6px; }
.seg {
  display: flex; align-items: center; gap: 3px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 4px;
}
.seg-label { font-size: 11px; color: var(--muted); padding: 0 4px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--muted); font-weight: 700;
  font-size: 13px; padding: 7px 0; border-radius: 8px; font-family: "Roboto", "Yekan Bakh", sans-serif;
}
.seg button.on { background: var(--primary); color: #fff; }
.seg.locked { opacity: .45; pointer-events: none; }
.trade-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trade-btns .btn { font-size: 17px; padding: 16px 6px; }

/* ---------- result ---------- */
.res-title { font-size: 22px; font-weight: 700; margin-top: 6px; }
.res-emoji { font-size: 48px; line-height: 1.2; margin: 4px 0; }
.res-balance-label { color: var(--muted); font-size: 13px; }
.res-balance { font-family: "Roboto", "Yekan Bakh", sans-serif; font-size: 40px; font-weight: 500; direction: ltr; }
.res-ret { font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; font-size: 18px; direction: ltr; margin-bottom: 14px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.res-grid > div {
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px; padding: 9px;
  display: flex; flex-direction: column; gap: 2px;
}
.res-grid .label { font-size: 12px; color: var(--muted); }
.res-grid b { font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; font-size: 17px; direction: ltr; }
.res-submit { min-height: 20px; margin-bottom: 10px; }
.res-actions { display: flex; flex-direction: column; gap: 8px; }

@media (max-height: 620px) {
  .stats .stat { padding: 3px 8px; }
  .trade-btns .btn { padding: 12px 6px; }
  .rules li { padding: 6px 10px; font-size: 13px; }
}

/* ---------- v2: pills, alerts, hint, daily board ---------- */
.warnc { color: var(--warn); }
#screen-intro, #screen-result { overflow-y: auto; justify-content: flex-start; }
.intro-card, .result-card { margin: auto 0; }
.daily-info { margin: 6px 0 12px; min-height: 18px; line-height: 1.8; }
#btn-start { margin-bottom: 4px; }
#intro-best { margin-top: 10px; }

.pills { display: flex; gap: 6px; }
.pill {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; white-space: nowrap; color: #D6DCE4; transition: all .2s;
}
.pill.mission { flex: 1; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pill.mission.done { border-color: rgba(84,210,215,.6); color: var(--teal); }
.pill.hot { border-color: rgba(245,165,36,.7); color: var(--warn); box-shadow: 0 0 12px -4px var(--warn); }
.pill.used { opacity: .4; }

.chart-wrap { transition: box-shadow .3s, border-color .3s; touch-action: none; }
.chart-wrap.alert { animation: alertPulse .5s ease-in-out infinite alternate; }
.chart-wrap.storm { border-color: rgba(239,68,68,.8); box-shadow: 0 0 0 1px rgba(239,68,68,.5), 0 0 28px -6px rgba(239,68,68,.8) inset; }
@keyframes alertPulse {
  from { border-color: var(--border); box-shadow: none; }
  to { border-color: var(--warn); box-shadow: 0 0 24px -6px var(--warn) inset; }
}
.news.warn { border-color: rgba(245,165,36,.8); }

.hint {
  position: absolute; bottom: 30px; left: 50%; transform: translate(-50%, 12px); opacity: 0;
  background: rgba(74,143,253,.92); color: #fff; font-size: 12.5px; border-radius: 10px; padding: 7px 12px;
  white-space: nowrap; transition: opacity .3s, transform .3s; pointer-events: none;
}
.hint.show { opacity: 1; transform: translate(-50%, 0); }
.floater.wide { font-family: "Yekan Bakh", sans-serif; font-size: 24px; }

.board { margin-top: 12px; text-align: right; }
.board-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--muted); }
.board-row {
  display: flex; align-items: center; gap: 8px; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 10px; margin-bottom: 5px; font-size: 14px;
}
.board-row.me { border-color: var(--primary); }
.board-row .rk { width: 22px; text-align: center; }
.board-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row b { font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; }

.res-mode { color: var(--muted); font-size: 13px; }
.res-mission {
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 10px; font-size: 13.5px; margin-bottom: 12px; color: var(--muted);
}
.res-mission.ok { border-color: rgba(84,210,215,.6); color: var(--teal); }
.pill .rw { color: var(--warn); font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; }

/* ---------- v3: mini app, greeting, leaderboard ---------- */
:root { --gold: #F5C542; --silver: #C9D1DC; --bronze: #D99058; }
.btn-gold { background: linear-gradient(180deg, #2A2414, #1D1A10); border: 1px solid rgba(245,197,66,.55); color: var(--gold); }
.btn-sm { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.intro-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.intro-actions .btn-lg { font-size: 16px; padding: 14px 8px; }

.who { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 2px; font-size: 14px; color: #D6DCE4; }
.group-pick {
  font-family: inherit; font-size: 13px; color: var(--text); background: var(--surface-3);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; max-width: 220px;
}
.group-pick:disabled { opacity: 1; appearance: none; -webkit-appearance: none; }

#screen-board {
  padding: 10px 12px 0;
  background:
    radial-gradient(520px 260px at 50% -40px, rgba(245,197,66,.16), transparent 70%),
    radial-gradient(600px 300px at 50% 0, rgba(74,143,253,.18), transparent 70%),
    var(--bg);
}
.board-head { display: flex; align-items: center; gap: 10px; }
.bh-title { display: flex; flex-direction: column; flex: 1; }
.bh-title b { font-size: 20px; font-weight: 700; }
.bh-logo { width: 31px; height: 29px; opacity: .9; }
.tg-app #board-back { display: none; } /* Telegram shows its own back button */

.lb-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 4px;
}
.lb-tabs button {
  border: 0; background: transparent; color: var(--muted); font-family: inherit; font-weight: 600;
  font-size: 12.5px; padding: 9px 2px; border-radius: 10px; transition: background .2s, color .2s;
}
.lb-tabs button.on { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -8px var(--primary); }
.board-sub { color: var(--muted); font-size: 12.5px; text-align: center; margin: 10px 0 2px; min-height: 18px; }
.board-body { flex: 1; overflow-y: auto; padding-bottom: 86px; -webkit-overflow-scrolling: touch; }

/* avatar: initials under, photo on top when available */
.av {
  position: relative; flex: none; width: var(--s); height: var(--s); border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--c1), var(--c2)); display: inline-flex; align-items: center; justify-content: center;
}
.av i { font-style: normal; font-weight: 700; color: #fff; font-size: calc(var(--s) * .38); font-family: "Roboto", "Yekan Bakh", sans-serif; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* podium */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; padding: 26px 4px 6px; }
.pd-col { flex: 1; max-width: 132px; display: flex; flex-direction: column; align-items: center; position: relative; animation: rise .5s cubic-bezier(.2,.9,.3,1.2) both; }
.pd-col.empty { visibility: hidden; }
.pd-1 { animation-delay: .05s; } .pd-2 { animation-delay: .15s; } .pd-3 { animation-delay: .25s; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.pd-col .av { border: 3px solid var(--ring); box-shadow: 0 0 0 4px rgba(0,0,0,.35), 0 10px 26px -8px var(--ring); }
.pd-1 { --ring: var(--gold); } .pd-2 { --ring: var(--silver); } .pd-3 { --ring: var(--bronze); }
.crown { position: absolute; top: -26px; font-size: 26px; filter: drop-shadow(0 4px 10px rgba(245,197,66,.6)); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-6deg); } }
.pd-name { margin-top: 8px; font-size: 13.5px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-score {
  margin-top: 4px; font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; font-size: 13px;
  color: var(--ring); background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 999px; padding: 2px 10px;
}
.pd-base {
  width: 100%; margin-top: 10px; border-radius: 14px 14px 4px 4px; display: flex; align-items: flex-start; justify-content: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--ring) 32%, #141920), #141920 85%);
  border: 1px solid color-mix(in srgb, var(--ring) 45%, transparent); border-bottom: 0;
}
.pd-base span { font-family: "Roboto", sans-serif; font-weight: 500; font-size: 26px; color: var(--ring); margin-top: 8px; }
.pd-1 .pd-base { height: 96px; } .pd-2 .pd-base { height: 70px; } .pd-3 .pd-base { height: 54px; }
.pd-col.me .pd-name { color: var(--primary); }

/* list */
.lb-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.lb-row {
  display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px 12px; animation: slideIn .35s ease both;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.lb-row.me { border-color: var(--primary); background: rgba(74,143,253,.10); }
.lb-rank { width: 26px; text-align: center; color: var(--muted); font-weight: 700; font-size: 14px; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.lb-name em { font-style: normal; color: var(--primary); font-size: 12px; }
.lb-score { font-family: "Roboto", "Yekan Bakh", sans-serif; font-weight: 500; font-size: 14.5px; color: #E6EBF2; }

/* my rank, pinned */
.board-me {
  position: absolute; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(74,143,253,.95), rgba(28,86,173,.95)); box-shadow: 0 12px 30px -10px rgba(74,143,253,.7);
  font-size: 14px;
}
.board-me > span:not(.av) { flex: 1; }
.board-me .lb-score { color: #fff; }
.board-me .btn-primary { background: #fff; color: var(--primary-2); box-shadow: none; }

.lb-empty { text-align: center; padding: 48px 20px; color: #C9D1DC; line-height: 1.9; }
.lb-empty .em { font-size: 46px; margin-bottom: 6px; }
.lb-empty .btn { margin-top: 10px; padding: 10px 26px; }
.lb-skel {
  height: 54px; border-radius: 14px; margin-top: 8px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.lb-skel:first-child { height: 170px; margin-top: 20px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- v4: game logo in the header ---------- */
.rush-icon {
  width: 84px; height: 84px; border-radius: 50%; display: block; margin: 0 auto;
  box-shadow: 0 0 0 1px rgba(140,189,255,.25), 0 14px 40px -12px rgba(74,143,253,.75);
  animation: rushIn .6s cubic-bezier(.2,.9,.3,1.25) both;
}
@keyframes rushIn { from { opacity: 0; transform: scale(.7) rotate(-12deg); } to { opacity: 1; transform: none; } }
.rush-title { font-size: 30px; font-weight: 700; margin: 10px 0 0; letter-spacing: -.3px; }
.rush-tag { font-size: 15px; font-weight: 600; color: #C9D1DC; margin-top: 2px; }
.intro-card .rules { margin-top: 4px; }
.intro-card .brand-logo { height: 22px; margin: 10px auto 12px; opacity: .8; filter: none; }
