@font-face { font-family: Vazirmatn; src: url(../fonts/Vazirmatn-FD-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(../fonts/Vazirmatn-FD-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(../fonts/Vazirmatn-FD-Black.woff2) format('woff2'); font-weight: 900; font-display: swap; }

:root {
  --bg: #0a0f1e;
  --bg2: #111a33;
  --panel: rgba(20, 30, 58, 0.78);
  --panel2: rgba(31, 45, 84, 0.9);
  --line: rgba(140, 170, 255, 0.16);
  --text: #eef3ff;
  --muted: #93a3c8;
  --gold: #ffc93c;
  --gold2: #f39c12;
  --accent: #36c2ff;
  --green: #2fd67b;
  --red: #ff4d5e;
  --sat: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --sab: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; }
body { font-family: Vazirmatn, Tahoma, sans-serif; -webkit-user-select: none; user-select: none; touch-action: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
img { -webkit-user-drag: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

#app { position: fixed; inset: 0; overflow: hidden; background: radial-gradient(120% 80% at 50% 0%, #17244a 0%, var(--bg) 60%); }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

.coin { display: inline-block; width: 18px; height: 18px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff6c4 0 12%, #ffd34d 30%, #e59a0b 75%, #a8650a 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 240, 180, .55), 0 1px 2px rgba(0,0,0,.5); }

/* ---------- splash ---------- */
#splash { align-items: center; justify-content: center; gap: 14px; }
.splash-glow { position: absolute; width: 140vw; height: 140vw; max-width: 900px; max-height: 900px; border-radius: 50%;
  background: radial-gradient(circle, rgba(54, 120, 255, .28), transparent 60%); animation: pulse 3s ease-in-out infinite; }
.splash-logo { width: 170px; height: 170px; border-radius: 50%; position: relative; animation: float 3s ease-in-out infinite;
  -webkit-mask: radial-gradient(circle, #000 58%, transparent 71%); mask: radial-gradient(circle, #000 58%, transparent 71%); }
.title { margin: 0; font-weight: 900; font-size: 34px; letter-spacing: -.5px; position: relative;
  text-shadow: 0 4px 18px rgba(0,0,0,.6); }
.title span { color: var(--gold); }
.loadbar { width: 200px; height: 8px; border-radius: 8px; background: rgba(255,255,255,.08); overflow: hidden; position: relative; }
.loadbar i { position: absolute; inset: 0 100% 0 0; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 8px; transition: right .3s; }
@keyframes pulse { 50% { transform: scale(1.08); opacity: .8; } }
@keyframes float { 50% { transform: translateY(-8px); } }

/* ---------- lobby ---------- */
#lobby { overflow-y: auto; touch-action: pan-y; padding: calc(var(--sat) + 10px) 14px calc(var(--sab) + 18px); gap: 12px; }
.lobby-bg { position: fixed; inset: 0; background: url(../assets/lobby.webp) center top / cover no-repeat; opacity: .55; pointer-events: none; }
.lobby-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,15,30,.3) 0%, rgba(10,15,30,.65) 45%, var(--bg) 85%); }
#lobby > * { position: relative; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ava { width: 46px; height: 46px; border-radius: 50%; background: #23315c center / cover no-repeat; flex: none;
  display: grid; place-items: center; font-weight: 900; font-size: 20px; color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.2); overflow: hidden; }
.me-info { min-width: 0; }
.me-info b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.lvl { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.xpbar { width: 70px; height: 6px; border-radius: 6px; background: rgba(255,255,255,.1); overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #36c2ff, #7b6cff); border-radius: 6px; }
.coins { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); padding: 6px 8px 6px 6px; border-radius: 30px; backdrop-filter: blur(8px); }
.coins b { font-size: 15px; min-width: 40px; text-align: center; }
.coins .plus { width: 20px; height: 20px; border-radius: 50%; background: var(--green); color: #052; font-weight: 900; display: grid; place-items: center; line-height: 1; }
.coins.ready .plus { animation: bonus 1.2s ease-in-out infinite; }
@keyframes bonus { 50% { transform: scale(1.25); box-shadow: 0 0 12px var(--green); } }

.hero { text-align: center; margin-top: 2px; }
.hero-logo { width: 116px; height: 116px; -webkit-mask: radial-gradient(circle, #000 58%, transparent 71%); mask: radial-gradient(circle, #000 58%, transparent 71%); filter: drop-shadow(0 8px 24px rgba(255, 200, 60, .25)); }
.hero .title { font-size: 30px; margin-top: -6px; }
.hero p { margin: 2px 0 0; font-size: 13px; }

.section-title { margin: 6px 2px 0; font-size: 15px; font-weight: 700; color: #cfe0ff; }
.opps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.opp { position: relative; border-radius: 18px; padding: 10px 8px 10px; text-align: center; overflow: hidden;
  background: linear-gradient(180deg, rgba(40, 60, 115, .85), rgba(18, 27, 54, .92)); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.08); transition: transform .15s; }
.opp:active { transform: scale(.97); }
.opp.hard { background: linear-gradient(180deg, rgba(110, 30, 40, .85), rgba(30, 12, 20, .95)); }
.opp.medium { background: linear-gradient(180deg, rgba(120, 70, 20, .8), rgba(35, 22, 12, .95)); }
.opp img { width: 74px; height: 74px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 6px;
  box-shadow: 0 0 0 3px rgba(255,255,255,.18), 0 6px 18px rgba(0,0,0,.5); }
.opp b { display: block; font-size: 15px; }
.opp .tag { font-size: 11px; color: var(--muted); }
.opp .fee { margin-top: 7px; display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.opp .fee div { display: flex; align-items: center; justify-content: center; gap: 4px; }
.opp .fee .coin { width: 13px; height: 13px; }
.opp .go { margin-top: 8px; width: 100%; padding: 7px 0; border-radius: 12px; font-weight: 900; font-size: 14px;
  background: linear-gradient(180deg, #ffd65a, #f0a015); color: #3b2300; box-shadow: 0 3px 0 #a86200, 0 6px 14px rgba(240,160,20,.35); }
.opp.locked .go { filter: grayscale(1) brightness(.7); }
.stars { color: var(--gold); font-size: 11px; letter-spacing: 1px; }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px; }
.qbtn { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 2px; font-size: 12px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 4px; backdrop-filter: blur(6px); }
.qbtn .ic { font-size: 22px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 14px; padding: 8px 4px; text-align: center; }
.stat b { display: block; font-size: 17px; }
.stat span { font-size: 11px; color: var(--muted); }

/* ---------- game ---------- */
#game { background: radial-gradient(100% 60% at 50% 45%, #1a2850 0%, #0b1122 75%); }
.hud { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: calc(var(--sat) + 8px) 10px 6px; }
.pcard { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; padding: 6px 8px 7px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line); transition: box-shadow .3s, border-color .3s; }
.ptop { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pcard.right .ptop { flex-direction: row-reverse; }
.pcard.active { border-color: rgba(255, 210, 80, .7); box-shadow: 0 0 0 1px rgba(255,210,80,.35), 0 0 22px rgba(255, 190, 40, .25); }
.ava-wrap { position: relative; width: 44px; height: 44px; flex: none; }
.ava-wrap .ava { position: absolute; inset: 4px; width: auto; height: auto; font-size: 16px; }
.timer { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke: var(--gold); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 289; stroke-dashoffset: 289; transition: stroke .3s; }
.pcard.active .timer circle { stroke-dashoffset: 0; }
.timer.warn circle { stroke: var(--red); }
.pname { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pballs { display: flex; gap: 3px; justify-content: center; min-height: 15px; align-items: center; }
.pballs img, .pballs i { width: 15px; height: 15px; border-radius: 50%; flex: none; }
.pballs i { background: rgba(255,255,255,.1); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
.pballs img.gone { opacity: .18; filter: grayscale(1); }
.pot { flex: none; text-align: center; width: 54px; }
.vs { font-weight: 900; font-style: italic; font-size: 18px; color: #fff; text-shadow: 0 0 12px rgba(80,150,255,.8); }
.stake { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; background: rgba(0,0,0,.35); padding: 2px 7px; border-radius: 20px; margin-top: 2px; }
.stake .coin { width: 13px; height: 13px; }

.stage { position: relative; flex: 1; min-height: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ov { touch-action: none; }

.power { position: absolute; top: 50%; transform: translateY(-50%); width: 34px; height: 56%; max-height: 420px; z-index: 3; touch-action: none; }
.pw-track { position: absolute; inset: 0; border-radius: 18px; overflow: hidden;
  background: linear-gradient(90deg, rgba(0,0,0,.7), rgba(30,40,70,.75), rgba(0,0,0,.7)); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.18), 0 6px 20px rgba(0,0,0,.6); }
.pw-fill { position: absolute; left: 0; right: 0; top: 0; height: 0; background: linear-gradient(180deg, #ffe066, #ff9f1a 50%, #ff3d3d); opacity: .9; }
.pw-cue { position: absolute; left: 50%; width: 10px; margin-left: -5px; top: 6px; bottom: -40%; border-radius: 6px;
  background: linear-gradient(180deg, #2f6fd6 0 7px, #f3efe6 7px 16px, #e9d4a9 16px 55%, #7a3c14 55%, #2a1206); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.pw-label { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); font-weight: 900; font-size: 13px; color: var(--gold); white-space: nowrap; text-shadow: 0 2px 6px #000; }
.power.disabled { opacity: .35; pointer-events: none; }

.fine { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 42%; max-height: 320px; z-index: 3; border-radius: 16px; overflow: hidden; touch-action: none;
  background: linear-gradient(90deg, #111, #3b4560 50%, #111); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.18), 0 6px 20px rgba(0,0,0,.6); }
.fine-wheel { position: absolute; inset: 0; background: repeating-linear-gradient(180deg, rgba(255,255,255,.55) 0 2px, transparent 2px 9px);
  -webkit-mask: linear-gradient(180deg, transparent, #000 25%, #000 75%, transparent); mask: linear-gradient(180deg, transparent, #000 25%, #000 75%, transparent); }
.fine.disabled { opacity: .35; pointer-events: none; }

.banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none; z-index: 5;
  padding: 12px 22px; border-radius: 18px; background: linear-gradient(180deg, rgba(25,38,80,.95), rgba(12,18,40,.95)); border: 1px solid rgba(255,255,255,.18);
  font-weight: 900; font-size: 19px; white-space: nowrap; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.6); transition: transform .25s cubic-bezier(.2,1.4,.4,1), opacity .2s; }
.banner small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner.foul { background: linear-gradient(180deg, rgba(120,20,30,.96), rgba(60,8,16,.96)); }
.banner.good { background: linear-gradient(180deg, rgba(20,100,60,.96), rgba(8,50,30,.96)); }
.toast { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 5; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: rgba(0,0,0,.65); padding: 6px 14px; border-radius: 20px; font-size: 13px; white-space: nowrap; }
.toast.show { opacity: 1; }
.hint { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 4; pointer-events: none; font-size: 12px; color: #dfe8ff;
  background: rgba(0,0,0,.45); padding: 4px 12px; border-radius: 14px; opacity: 0; transition: opacity .3s; white-space: nowrap; }
.hint.show { opacity: 1; }

.bottombar { flex: none; display: flex; align-items: center; gap: 10px; padding: 6px 12px calc(var(--sab) + 10px); }
.round { width: 44px; height: 44px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; flex: none; }
.round svg { width: 22px; height: 22px; }
.tray { flex: 1; height: 34px; border-radius: 20px; position: relative; overflow: hidden;
  background: linear-gradient(180deg, #05070d, #1a2238 60%, #0b0f1a); box-shadow: inset 0 3px 8px rgba(0,0,0,.9), 0 0 0 1px rgba(255,255,255,.08); }
.tray-in { position: absolute; inset: 3px 8px; display: flex; flex-direction: row-reverse; gap: 1px; align-items: center; direction: ltr; }
.tray-in img { width: 28px; height: 28px; flex: none; animation: rollin .9s cubic-bezier(.3,.7,.3,1) both; }
@keyframes rollin { from { transform: translateX(-340px) rotate(-720deg); } to { transform: none; } }
.spinbtn { width: 50px; height: 50px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); }
.spinball { width: 38px; height: 38px; border-radius: 50%; position: relative; background: radial-gradient(circle at 35% 30%, #fff 0 10%, #f1ede2 40%, #b9b4a8 100%); box-shadow: 0 2px 6px rgba(0,0,0,.6); }
.spinball i, .bigball i { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: #e0242f; left: 50%; top: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 2px rgba(255,255,255,.7); }

/* ---------- overlays ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; }
.overlay.show { display: flex; }
.modal { background: rgba(3, 6, 15, .66); backdrop-filter: blur(6px); padding: 20px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.card { width: min(360px, 100%); background: linear-gradient(180deg, #1b2a55, #0f1731); border: 1px solid rgba(255,255,255,.14); border-radius: 24px; padding: 18px;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); position: relative; animation: pop .3s cubic-bezier(.2,1.4,.4,1); max-height: 86vh; overflow-y: auto; touch-action: pan-y; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.card h3 { margin: 0 0 6px; font-size: 18px; }
.btnrow { display: flex; gap: 10px; margin-top: 14px; }
.btnrow .btn { flex: 1; }
.btn { padding: 12px 14px; border-radius: 14px; font-weight: 900; font-size: 15px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14); }
.btn.primary { background: linear-gradient(180deg, #ffd65a, #f0a015); color: #3b2300; border: 0; box-shadow: 0 4px 0 #a86200; }
.btn.danger { background: rgba(255, 77, 94, .16); color: #ff8a95; border-color: rgba(255,77,94,.4); }
.btn.wide { display: block; width: 100%; margin-top: 10px; }
.close { position: absolute; top: 10px; left: 12px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 15px; }

.bigball { width: 210px; height: 210px; border-radius: 50%; margin: 14px auto 4px; position: relative; touch-action: none;
  background: radial-gradient(circle at 36% 30%, #fff 0 8%, #f3efe4 35%, #cfc9bb 75%, #8f8a7f 100%); box-shadow: 0 12px 30px rgba(0,0,0,.6), inset 0 -8px 24px rgba(0,0,0,.25); }
.bigball .cross { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent calc(50% - .5px), rgba(0,0,0,.18) calc(50% - .5px) calc(50% + .5px), transparent 0),
              linear-gradient(0deg, transparent calc(50% - .5px), rgba(0,0,0,.18) calc(50% - .5px) calc(50% + .5px), transparent 0); border-radius: 50%; }
.bigball i { width: 26px; height: 26px; z-index: 2; box-shadow: 0 0 0 3px rgba(255,255,255,.9), 0 3px 8px rgba(0,0,0,.5); }

#vs { background: radial-gradient(circle at 50% 50%, rgba(30,60,140,.9), rgba(5,8,20,.97)); gap: 4px; }
.vs-side { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 38%; transition: transform .5s cubic-bezier(.2,1.3,.4,1), opacity .4s; }
.vs-side b { font-size: 17px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-side.l { transform: translateX(120%); opacity: 0; }
.vs-side.r { transform: translateX(-120%); opacity: 0; }
#vs.go .vs-side { transform: none; opacity: 1; }
.ava.big { width: 104px; height: 104px; font-size: 40px; box-shadow: 0 0 0 4px var(--gold), 0 0 40px rgba(255,200,60,.35); }
.vs-mid { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.vs-txt { font-size: 46px; font-weight: 900; font-style: italic; color: #fff; text-shadow: 0 0 24px #3a8bff, 0 0 4px #fff; transform: scale(0); transition: transform .4s .25s cubic-bezier(.2,1.6,.4,1); }
#vs.go .vs-txt { transform: scale(1); }
.stake.big { font-size: 16px; padding: 4px 12px; }
.stake.big .coin { width: 18px; height: 18px; }

.result-card { overflow: hidden; padding-top: 6px; }
.result-card .rays { position: absolute; left: 50%; top: 90px; width: 520px; height: 520px; margin: -260px 0 0 -260px; pointer-events: none; opacity: .35;
  background: repeating-conic-gradient(rgba(255,210,90,.5) 0 8deg, transparent 8deg 24deg); border-radius: 50%; animation: spin 14s linear infinite;
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 65%); mask: radial-gradient(circle, #000 20%, transparent 65%); }
.result-card.lose .rays { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-card img { width: 150px; height: 150px; object-fit: cover; border-radius: 50%; position: relative; margin-top: 10px; }
.result-card h2 { margin: 6px 0 2px; font-size: 30px; font-weight: 900; position: relative; }
.result-card.win h2 { color: var(--gold); }
.reward { display: flex; justify-content: center; gap: 10px; margin-top: 10px; position: relative; }
.reward div { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.3); padding: 6px 12px; border-radius: 14px; font-weight: 900; }

.sheet-card { text-align: right; }
.sheet-card h3 { text-align: center; }
.cue-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 16px; background: rgba(255,255,255,.05); border: 1px solid var(--line); margin-top: 8px; }
.cue-item.sel { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(255,201,60,.4); }
.cue-item canvas { width: 150px; height: 18px; flex: none; }
.cue-item .ci { flex: 1; min-width: 0; }
.cue-item .ci b { display: block; }
.cue-item .bars { display: flex; gap: 2px; margin-top: 3px; font-size: 10px; color: var(--muted); align-items: center; }
.cue-item .bars i { width: 10px; height: 5px; border-radius: 2px; background: rgba(255,255,255,.15); }
.cue-item .bars i.on { background: var(--accent); }
.cue-item .buy { padding: 7px 10px; border-radius: 12px; font-weight: 900; font-size: 13px; background: rgba(255,255,255,.1); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.cue-item .buy.gold { background: linear-gradient(180deg, #ffd65a, #f0a015); color: #3b2300; }
.cue-item .buy .coin { width: 13px; height: 13px; }
.row { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.switch { width: 46px; height: 26px; border-radius: 20px; background: rgba(255,255,255,.15); position: relative; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: right .2s; }
.switch.on { background: var(--green); }
.switch.on::after { right: 23px; }
.felts { display: flex; gap: 8px; }
.felts button { width: 32px; height: 32px; border-radius: 10px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.15); }
.felts button.sel { box-shadow: 0 0 0 2px var(--gold); }
.help p { margin: 8px 0; font-size: 14px; line-height: 1.9; }
.help b { color: var(--gold); }
