:root {
  --bg: #0b0a14; --bg2: #12101f; --panel: #181530; --panel2: #1f1b3d; --line: #2e2858;
  --gold: #e3b94f; --gold2: #c99a2e; --violet: #7a58e6; --violet2: #5a3fc0;
  --text: #f4eedb; --muted: #a9a1c8; --green: #43c27a; --red: #ef5b5b;
  --radius: 14px;
  font-family: Vazirmatn, "Segoe UI", Tahoma, "Noto Sans Arabic", "DejaVu Sans", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: radial-gradient(1200px 600px at 80% -10%, #2a1f5a55, transparent), radial-gradient(900px 500px at 0% 0%, #5a3fc022, transparent), var(--bg); color: var(--text); line-height: 1.85; min-height: 100vh; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.5; margin: 0 0 10px; }
h1 { font-size: 24px; } h2 { font-size: 18px; color: var(--gold); }
p { margin: 8px 0; }
button { font: inherit; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.money { direction: ltr; unicode-bidi: isolate; white-space: nowrap; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 18px; background: #0b0a14ee; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo { font-weight: 800; font-size: 24px; letter-spacing: 1px; background: linear-gradient(90deg, var(--gold), #fff2c4 50%, var(--gold2)); -webkit-background-clip: text; background-clip: text; color: transparent; direction: ltr; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 0 8px; border-radius: 99px; }
.nav { display: flex; gap: 4px; margin-inline-start: 8px; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 10px; }
.nav a.on, .nav a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
.balance { margin-inline-start: auto; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; min-width: 170px; }
.bal-lbl { font-size: 12px; color: var(--muted); }
.bal-val { font-size: 19px; font-weight: 700; color: var(--gold); }
.bal-val.flash { animation: flash .9s ease; }
@keyframes flash { 0% { color: #fff; text-shadow: 0 0 14px var(--gold); } 100% { color: var(--gold); text-shadow: none; } }
.conn { color: var(--green); font-size: 11px; margin-inline-start: 4px; } .conn.off { color: var(--red); }
.offline-banner { background: #5a1f1f; color: #ffd7d7; text-align: center; padding: 8px; font-size: 14px; }
.offline-banner[hidden] { display: none; }

.main { max-width: 1060px; margin: 0 auto; padding: 18px 16px 40px; }
.page { display: block; }
.hero { padding: 26px 22px; border-radius: 20px; background: linear-gradient(135deg, #261d56, #14102c 60%); border: 1px solid var(--line); margin-bottom: 20px; }
.hero h1 { font-size: 26px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 20px; }
.game-card { display: block; background: linear-gradient(160deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; color: var(--text); transition: transform .18s, border-color .18s, box-shadow .18s; }
.game-card:hover { text-decoration: none; transform: translateY(-3px); border-color: var(--gold2); box-shadow: 0 10px 30px #0008, 0 0 0 1px #e3b94f33; }
.gc-icon { font-size: 34px; } .gc-title { font-size: 19px; font-weight: 700; color: var(--gold); margin-top: 4px; }
.gc-blurb { color: var(--muted); font-size: 14px; min-height: 48px; } .gc-go { margin-top: 8px; font-size: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.how ol { margin: 6px 0 0; padding-inline-start: 22px; }
.prose .panel { margin-bottom: 14px; } .prose ul { margin: 6px 0; padding-inline-start: 20px; }

/* game layout */
.game-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.game-head h1 { margin: 0; } .back { font-size: 14px; }
.game-layout { display: grid; grid-template-columns: 330px 1fr; gap: 14px; align-items: start; }
.game-layout .rules { grid-column: 1 / -1; }
.rules summary { cursor: pointer; font-weight: 700; color: var(--gold); } .rules div { margin-top: 8px; color: #e6dfc7; font-size: 14.5px; }
.controls { display: flex; flex-direction: column; gap: 12px; }
.stage { min-height: 340px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.lbl { font-size: 13px; color: var(--muted); }
.betbox { display: flex; flex-direction: column; gap: 6px; }
.bet-input, .select { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: #100d24; color: #fff; font-size: 18px; text-align: center; direction: ltr; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { flex: 1; min-width: 64px; padding: 8px 6px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; font-size: 13px; min-height: 40px; }
.chip:hover:not(:disabled) { border-color: var(--gold2); }
.btn { padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; font-weight: 700; min-height: 48px; transition: filter .15s, transform .1s; }
.btn:hover:not(:disabled) { filter: brightness(1.15); } .btn:active:not(:disabled) { transform: scale(.98); }
.btn.big { font-size: 17px; width: 100%; }
.btn.primary { background: linear-gradient(180deg, var(--violet), var(--violet2)); border-color: #9a82ff; color: #fff; }
.btn.gold { background: linear-gradient(180deg, #f3cd6a, var(--gold2)); border-color: #fff0b3; color: #2a1d00; }
.btn:disabled, .chip:disabled, .tile:disabled { opacity: .45; cursor: not-allowed; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; font-weight: 700; min-height: 48px; }
.seg.on { background: var(--gold); color: #2a1d00; border-color: #fff0b3; }
.info-row { display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 14px; color: var(--muted); } .info-row b { color: var(--text); }
.stage-msg { text-align: center; min-height: 26px; color: var(--gold); font-weight: 700; }
.result-slot { min-height: 72px; text-align: center; }
.banner { display: inline-block; min-width: 220px; padding: 10px 22px; border-radius: 14px; border: 1px solid; margin-top: 6px; animation: pop .35s ease; }
.banner.win { background: #123b27; border-color: var(--green); color: #aef0c8; } .banner.lose { background: #3b1620; border-color: var(--red); color: #ffc2c2; } .banner.push { background: #2c2a44; border-color: var(--muted); }
.b-title { font-size: 20px; font-weight: 800; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.notice { background: #2c2250; border: 1px solid var(--violet); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; }

/* coin */
.coin-wrap { perspective: 900px; display: grid; place-items: center; padding: 20px 0; }
.coin { width: 150px; height: 150px; position: relative; transform-style: preserve-3d; transition: transform 1.8s cubic-bezier(.2,.7,.2,1); }
.coin-face { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 800; color: #3a2800; backface-visibility: hidden; background: radial-gradient(circle at 35% 30%, #fff3b8, var(--gold) 55%, #9a6b10); border: 6px solid #f8de8a; box-shadow: inset 0 0 18px #7a520055, 0 8px 28px #0009; }
.coin-face.back { transform: rotateY(180deg); background: radial-gradient(circle at 35% 30%, #e8e4ff, #a894ff 55%, #5a3fc0); color: #1d1250; border-color: #cfc3ff; }

/* crash */
.crash-mult { text-align: center; font-size: 64px; font-weight: 800; color: var(--gold); direction: ltr; text-shadow: 0 0 22px #e3b94f55; transition: color .2s; }
.crash-mult.boom { color: var(--red); text-shadow: 0 0 26px #ef5b5b88; animation: shake .4s; } .crash-mult.cashed { color: var(--green); }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.crash-canvas { width: 100%; height: auto; background: #0f0c22; border: 1px solid var(--line); border-radius: 12px; }

/* plinko */
.plinko-wrap { max-width: 460px; margin: 0 auto; width: 100%; } .plinko-svg { width: 100%; height: auto; background: #0f0c22; border-radius: 12px; border: 1px solid var(--line); }
.peg { fill: #8f86c9; } .ball { fill: var(--gold); filter: drop-shadow(0 0 5px #e3b94f); }
.slot rect { fill: #2a2457; stroke: #4a3f98; } .slot text { fill: #fff; font-size: 9px; font-weight: 700; } .slot.hit rect { fill: var(--gold2); } .slot.hit text { fill: #1d1300; }
.slot:nth-child(n+1) { transition: transform .2s; } .slot.hit { transform: translateY(-3px); }

/* mines */
.mines-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 420px; margin: 0 auto; width: 100%; }
.tile { aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(160deg, #2b2560, #1b1742); color: #fff; font-size: 26px; cursor: pointer; min-height: 52px; }
.tile:hover:not(:disabled) { border-color: var(--gold2); transform: translateY(-2px); }
.tile.safe { background: linear-gradient(160deg, #12503a, #0c3426); border-color: var(--green); opacity: 1; }
.tile.mine { background: #3b1620; border-color: var(--red); opacity: .9; } .tile.boom { background: #7a1d2b; border-color: #ff8b8b; animation: shake .4s; } .tile.dim { opacity: .35; }
.tile:disabled { opacity: 1; cursor: default; } .tile.safe:disabled, .tile.boom:disabled { opacity: 1; } .tile:disabled:not(.safe):not(.boom):not(.mine):not(.dim) { opacity: .75; }

/* cards */
.seen { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; min-height: 54px; }
.hand { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; } .hand-box { padding: 8px; border-radius: 12px; border: 1px solid transparent; margin-bottom: 8px; } .hand-box.active { border-color: var(--gold); background: #ffffff0a; }
.bj-side { text-align: center; } .tot { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: #05040c; display: grid; place-items: center; padding: 16px; overflow: auto; }
.modal { max-width: 540px; width: 100%; background: linear-gradient(160deg, #241c52, #14102c); border: 1px solid var(--gold2); border-radius: 20px; padding: 24px; box-shadow: 0 20px 60px #000a; }
.modal h2 { font-size: 22px; } .warn-text { font-size: 17px; line-height: 2; }
.check { display: flex; align-items: center; gap: 10px; margin: 16px 0; cursor: pointer; font-size: 17px; } .check input { width: 22px; height: 22px; accent-color: var(--gold); }

/* tables, misc */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; min-width: 560px; } .tbl th, .tbl td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); } .tbl th { background: var(--panel2); color: var(--gold); font-size: 14px; }
.pos { color: var(--green); } .neg { color: var(--red); } .empty, .err-box { text-align: center; padding: 30px; }
.center-page { text-align: center; padding: 50px 10px; } .big-emoji { font-size: 56px; }
.footer { max-width: 1060px; margin: 0 auto; padding: 18px 16px 40px; color: var(--muted); font-size: 13px; text-align: center; border-top: 1px solid var(--line); }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast { background: #2b2460; border: 1px solid var(--violet); border-radius: 12px; padding: 10px 14px; animation: pop .25s ease; } .toast.err { background: #4a1a26; border-color: var(--red); }

@media (max-width: 760px) {
  .game-layout { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; gap: 8px; } .nav { order: 3; width: 100%; margin: 0; overflow-x: auto; } .balance { min-width: 0; padding: 2px 10px; }
  .crash-mult { font-size: 48px; } .hero h1 { font-size: 21px; } .main { padding: 12px 12px 30px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

.cfg-form { max-width: 460px; margin: 14px auto; text-align: right; display: flex; flex-direction: column; gap: 8px; } .bet-input.ltr { text-align: left; font-size: 15px; }

/* ===== cards (v2) ===== */
.pcard { position: relative; font-size: 15px; width: 4.2em; height: 6em; border-radius: .55em; background: linear-gradient(160deg, #ffffff, #f1ead2); color: #16122e; box-shadow: 0 .3em .9em #0008, inset 0 0 0 1px #d9d2b4; display: inline-block; user-select: none; direction: ltr; flex: none; }
.pcard .c { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.pcard .tl { top: .35em; left: .4em; } .pcard .br { bottom: .35em; right: .4em; transform: rotate(180deg); }
.pcard .c b { font-size: 1.25em; font-weight: 800; } .pcard .c i { font-style: normal; font-size: 1.05em; margin-top: .05em; }
.pcard .mid { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.6em; opacity: .92; }
.pcard.face .mid { font-family: Georgia, "Times New Roman", serif; font-weight: 800; font-size: 2.4em; background: linear-gradient(160deg, #3b2f7a, #b88a22); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pcard.red { color: #c9283d; } .pcard.red.face .mid { background: linear-gradient(160deg, #c9283d, #b88a22); -webkit-background-clip: text; background-clip: text; }
.pcard.back { background: repeating-linear-gradient(45deg, #3d2f8f, #3d2f8f .4em, #2a2063 .4em, #2a2063 .8em); box-shadow: 0 .3em .9em #0008, inset 0 0 0 .22em #cfc3ff, inset 0 0 0 .32em #3d2f8f; }
.pcard.back .mid { color: #e3b94f; font-size: 1.8em; opacity: .85; }
.pcard.mini { font-size: 8px; } .pcard.tiny { font-size: 9.5px; }
.hilo-card .pcard { font-size: 26px; }
.hilo-card { display: grid; place-items: center; padding: 10px; }
@keyframes dealIn { from { transform: translate(70px, -110px) rotate(-20deg) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes flipIn { 0% { transform: perspective(500px) rotateY(90deg) scale(.96); } 100% { transform: perspective(500px) rotateY(0); } }
.pcard.deal { animation: dealIn .55s cubic-bezier(.2,.8,.2,1) both; animation-delay: var(--d, 0ms); }
.pcard.reveal { animation: flipIn .55s ease both; animation-delay: var(--d, 0ms); }
.pcard.glow { box-shadow: 0 0 0 3px var(--gold), 0 0 26px #e3b94faa; }
.pcard.pick { cursor: pointer; transition: transform .15s; } .pcard.pick:hover { transform: translateY(-4px); } .pcard.pick.marked { transform: translateY(-14px); outline: 3px solid var(--gold); }
.seen { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; min-height: 54px; }
.hand { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; } .hand-box { padding: 8px; border-radius: 12px; border: 1px solid transparent; margin-bottom: 8px; } .hand-box.active { border-color: var(--gold); background: #ffffff0a; }
.bj-side { text-align: center; } .tot { color: var(--muted); font-size: 14px; margin-top: 4px; }
@media (max-width: 760px) { .pcard { font-size: 13.5px; } }

/* confetti, tiles, spinner */
#fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 150; }
.confetti { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .9; } }
.tile.safe, .tile.boom, .tile.mine { animation: tilePop .35s ease; } @keyframes tilePop { 0% { transform: scale(.6) rotate(-8deg); } 70% { transform: scale(1.12); } 100% { transform: none; } }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--gold); animation: spin 0.9s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Texas Hold'em table ===== */
.holdem { display: flex; flex-direction: column; gap: 10px; }
.table { position: relative; width: 100%; aspect-ratio: 16 / 11; min-height: 300px; max-height: 520px; }
.felt { position: absolute; inset: 7% 4%; border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, #1f7a55, #0f4a35 70%, #0a3425); border: 8px solid #3a2a14; box-shadow: inset 0 0 40px #0008, 0 10px 30px #000a, 0 0 0 2px #6b4a1f; }
.center-box { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: 80%; }
.pot { background: #0009; border: 1px solid #e3b94f66; padding: 2px 14px; border-radius: 99px; font-weight: 700; color: var(--gold); font-size: 14px; }
.street { font-size: 12px; color: #bde8d3; }
.board { display: flex; gap: 6px; justify-content: center; min-height: 6em; font-size: 13px; }
.slot-empty { width: 4.2em; height: 6em; border-radius: .55em; border: 2px dashed #ffffff30; }
.seat { position: absolute; transform: translate(-50%, -50%); width: 92px; text-align: center; font-size: 12px; transition: opacity .3s, filter .3s; }
.seat .av { width: 42px; height: 42px; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4b3d99, #231a55); border: 2px solid #8f82ea; display: grid; place-items: center; font-size: 22px; }
.seat.you .av { border-color: var(--gold); box-shadow: 0 0 12px #e3b94f88; }
.seat.turn .av { box-shadow: 0 0 0 3px #43c27a, 0 0 18px #43c27aaa; animation: pulse 1.1s infinite; }
.seat.folded { opacity: .38; filter: grayscale(.6); }
.seat.winner .av { box-shadow: 0 0 0 3px var(--gold), 0 0 26px #e3b94f; }
@keyframes pulse { 50% { transform: scale(1.07); } }
.seat .nm { font-weight: 700; margin-top: 2px; white-space: nowrap; } .seat .stk { color: var(--gold); font-size: 12px; }
.seat .lastact { color: #cfe9dd; font-size: 11px; min-height: 15px; } .seat .hn { color: #ffe9a8; font-size: 11px; font-weight: 700; }
.badge { display: inline-block; background: #fff; color: #222; border-radius: 99px; padding: 0 6px; font-size: 10px; font-weight: 800; margin-inline-start: 3px; } .badge.b2 { background: var(--violet); color: #fff; }
.chipbet { display: inline-block; margin-top: 2px; background: #0009; border: 1px solid #e3b94f88; color: #ffe9a8; border-radius: 99px; padding: 0 8px; font-size: 11px; animation: tilePop .3s ease; }
.bubble { position: absolute; left: 50%; top: -22px; transform: translateX(-50%); background: #fff; color: #1b1530; font-weight: 800; padding: 2px 10px; border-radius: 10px; font-size: 12px; white-space: nowrap; z-index: 5; animation: bub .9s ease forwards; box-shadow: 0 4px 12px #0007; }
@keyframes bub { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.8); } 15%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -8px); } }
.seat-cards { display: flex; gap: 2px; justify-content: center; margin-top: 2px; }
.hole { display: flex; gap: 10px; justify-content: center; min-height: 6.5em; font-size: 16px; }
.action-bar { display: flex; flex-direction: column; gap: 8px; }
.action-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.raise-box { display: flex; flex-direction: column; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.raise-box input[type=range] { width: 100%; accent-color: var(--gold); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.danger { background: #5a1f2b; border-color: #ef5b5b66; }
@media (max-width: 760px) { .table { aspect-ratio: 4 / 4.2; min-height: 340px; } .seat { width: 74px; font-size: 11px; } .seat .av { width: 36px; height: 36px; font-size: 18px; } .board { font-size: 10.5px; gap: 4px; } .hole { font-size: 14px; } }
.holdem .hole { margin-top: 26px; }
@media (max-width: 760px) { .holdem .hole { margin-top: 22px; } }
