:root {
  --night: #14163a; --night2: #1d2050; --night3: #2b3070;
  --turq: #35c4b5; --saffron: #f3b13f; --rose: #e8546f; --lapis: #5b7cff;
  --violet: #8a5cf0; --green: #2fae7a; --orange: #e0714a; --wine: #7a2f3f;
  --ivory: #f7f0df; --paper-ink: #2b2a3d; --muted: #a9acd6; --line: rgba(255,255,255,.12);
  --font: "Vazirmatn", "Vazir", Tahoma, "DejaVu Sans", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  min-height: 100vh; color: var(--ivory); font-family: var(--font); line-height: 1.7;
  background:
    radial-gradient(ellipse 80% 50% at 50% -5%, #3a3fa0 0, transparent 70%),
    repeating-conic-gradient(from 0deg at 50% 38%, rgba(255,255,255,.03) 0 7.5deg, transparent 7.5deg 15deg),
    var(--night);
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; cursor: pointer; border: 0; color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--turq); outline-offset: 2px; }
.wrap { max-width: 460px; margin: 0 auto; padding: 14px 14px 40px; }
.hidden { display: none !important; }

/* ---------- لابی ---------- */
.hero { text-align: center; padding: 34px 0 18px; }
.hero .emblem { font-size: 58px; filter: drop-shadow(0 6px 14px #0008); }
.hero h1 { margin: 6px 0 0; font-size: 2.5rem; font-weight: 900; color: var(--saffron); letter-spacing: -.5px; text-shadow: 0 3px 0 #8a5a0a, 0 10px 24px #0007; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.card { background: linear-gradient(180deg, var(--night2), #181b44); border: 1px solid var(--line); border-radius: 22px; padding: 18px; margin-top: 14px; box-shadow: 0 12px 30px #0005; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 0 0 6px; }
input { width: 100%; font: inherit; font-size: 1.05rem; color: var(--ivory); background: #0f1130; border: 1.5px solid var(--night3); border-radius: 14px; padding: 12px 14px; }
.btn { display: block; width: 100%; padding: 13px 18px; border-radius: 14px; font-weight: 800; font-size: 1rem; transition: transform .1s, filter .15s; }
.btn:active { transform: translateY(2px) scale(.99); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.gold { background: linear-gradient(180deg, #ffd17a, var(--saffron)); color: #3a2605; box-shadow: 0 4px 0 #a8710f, 0 10px 20px #0005; }
.btn.turq { background: linear-gradient(180deg, #62e3d5, var(--turq)); color: #04332e; box-shadow: 0 4px 0 #1e8b7f, 0 10px 20px #0005; }
.btn.ghost { background: transparent; border: 1.5px solid var(--night3); color: var(--ivory); }
.btn.rose { background: linear-gradient(180deg, #ff8aa0, var(--rose)); color: #3a0613; box-shadow: 0 4px 0 #a22a43; }
.row { display: flex; gap: 10px; align-items: stretch; }
.row > input { flex: 1; direction: ltr; text-align: center; letter-spacing: .3em; text-transform: uppercase; font-weight: 800; }
.row > .btn { width: auto; }
.divider { text-align: center; color: var(--muted); font-size: .8rem; margin: 14px 0; }
.err { color: #ff9eae; min-height: 1.6em; margin: 10px 0 0; font-size: .9rem; }

/* اتاق انتظار */
.codebox { text-align: center; }
.codebox .code { font-size: 3rem; font-weight: 900; letter-spacing: .25em; direction: ltr; color: var(--saffron); margin: 0; text-shadow: 0 3px 0 #8a5a0a; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.slot { border-radius: 16px; padding: 12px; min-height: 74px; display: flex; align-items: center; gap: 10px; background: #0f1130; border: 1.5px dashed var(--night3); color: var(--muted); }
.slot.filled { border: 1.5px solid var(--c); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 22%, #0f1130), #0f1130); color: var(--ivory); font-weight: 700; }
.pawn { width: 34px; height: 34px; border-radius: 50%; flex: none; background: radial-gradient(circle at 35% 30%, #fff9, transparent 45%), var(--c); box-shadow: inset 0 -4px 0 #0003, 0 3px 6px #0006; border: 2px solid #fff6; }

/* ---------- نوار بازیکن‌ها ---------- */
.chips { display: flex; gap: 6px; padding: 14px 2px 10px; }
.chip { flex: 1 1 0; min-width: 0; border-radius: 16px; padding: 8px 8px; background: var(--night2); border: 1.5px solid var(--line); text-align: right; transition: .2s; position: relative; }
.chip .nm { display: flex; align-items: center; gap: 5px; font-weight: 800; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .nm .pawn { width: 16px; height: 16px; border-width: 1.5px; }
.chip .cash { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.turn { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 40%, transparent), 0 0 18px color-mix(in srgb, var(--c) 45%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 20%, var(--night2)), var(--night2)); }
.chip.viewing::after { content: ""; position: absolute; inset-inline: 14px; bottom: -6px; height: 4px; border-radius: 4px; background: var(--ivory); }
.chip .tag { position: absolute; top: -7px; left: 8px; background: var(--c); color: #1a1a2e; font-size: .65rem; font-weight: 900; padding: 0 7px; border-radius: 8px; }

/* ---------- چرخ بازی ---------- */
.wheel { position: relative; width: min(100%, 440px); aspect-ratio: 1; margin: 6px auto 4px; direction: ltr; }
.wheel .plate { position: absolute; inset: 1.5%; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #2a2f78 0, #181b48 62%, #10123a 100%);
  border: 3px solid var(--saffron); box-shadow: 0 0 0 6px #14163a, 0 0 0 8px rgba(243,177,63,.35), 0 24px 50px #000a, inset 0 0 40px #0008; }
.wheel .plate::after { content: ""; position: absolute; inset: 20%; border-radius: 50%; border: 1.5px dashed rgba(243,177,63,.28); }
.tile { position: absolute; width: 9.4%; height: 13.2%; border-radius: 10px 10px 6px 6px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 7% 0 6%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--t) 100%, #fff 18%), var(--t)); border: 1.5px solid rgba(255,255,255,.35); box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.tile .ic { font-size: clamp(11px, 3.9vw, 17px); line-height: 1; }
.tile .toks { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; min-height: 8px; width: 100%; }
.tok { width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff9, transparent 50%), var(--c); border: 1.5px solid #fff; box-shadow: 0 1px 3px #000a; }
.tok.active { animation: bob 1s ease-in-out infinite; box-shadow: 0 0 0 2px var(--c), 0 0 10px var(--c); }
@keyframes bob { 50% { transform: translateY(-3px); } }
.tile.here { box-shadow: 0 0 0 2.5px #fff, 0 0 18px 4px var(--t); z-index: 2; }
.center { position: absolute; inset: 24%; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 6px;
  background: radial-gradient(circle at 50% 30%, #343a8c, #1a1d4d 70%); border: 2px solid rgba(243,177,63,.4); box-shadow: inset 0 0 30px #0009; direction: rtl; }
.center .who { font-size: clamp(.7rem, 3.2vw, .85rem); color: var(--muted); line-height: 1.3; }
.center .who b { color: var(--saffron); display: block; font-size: 1.05em; }
.center .go { width: auto; padding: 8px 16px; font-size: clamp(.85rem, 3.8vw, 1rem); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { filter: brightness(1.15); transform: scale(1.04); } }
.dice { display: flex; gap: 8px; }
.die { width: clamp(34px, 11vw, 48px); aspect-ratio: 1; border-radius: 22%; background: linear-gradient(145deg, #fff, #d9d0b8); box-shadow: 0 4px 0 #8f866c, 0 8px 14px #0007; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 15%; gap: 2%; }
.die i { border-radius: 50%; background: #25243a; opacity: 0; }
.die i.on { opacity: 1; }
.die.rolling { animation: tumble .6s cubic-bezier(.3,1.4,.5,1); }
@keyframes tumble { 0% { transform: rotate(-200deg) scale(.4); } 100% { transform: rotate(0) scale(1); } }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; font-size: .72rem; color: var(--muted); margin: 6px 0 2px; }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--t); margin-inline-end: 4px; }

/* ---------- تب‌ها و برگه‌ی مالی ---------- */
.tabs { display: flex; gap: 6px; background: #0f1130; border-radius: 16px; padding: 5px; margin-top: 12px; }
.tabs button { flex: 1; padding: 9px 6px; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 700; font-size: .88rem; }
.tabs button.on { background: var(--night3); color: var(--ivory); box-shadow: 0 2px 0 #0006; }
.paper { margin-top: 10px; border-radius: 18px; padding: 16px; color: var(--paper-ink); box-shadow: 0 12px 26px #0006;
  background: repeating-linear-gradient(180deg, transparent 0 29px, rgba(70,60,120,.06) 29px 30px), var(--ivory); position: relative; }
.paper h3 { margin: 0; font-size: 1.15rem; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.paper .sub { font-size: .8rem; color: #6a6785; margin: 0 0 10px; }
.escape { margin: 10px 0 14px; }
.escape .lbl { display: flex; justify-content: space-between; font-size: .78rem; font-weight: 700; color: #4a476a; margin-bottom: 4px; }
.bar { height: 16px; border-radius: 10px; background: #d9d0b8; box-shadow: inset 0 2px 4px #0003; position: relative; overflow: hidden; }
.bar > i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 10px; background: linear-gradient(90deg, var(--turq), var(--green)); transition: width .6s cubic-bezier(.3,1.2,.5,1); }
.escape .hint { font-size: .72rem; color: #6a6785; margin-top: 4px; }
.sec { font-size: .72rem; font-weight: 900; letter-spacing: .04em; color: var(--lapis); margin: 12px 0 2px; border-bottom: 2px solid rgba(91,124,255,.3); }
.ln { display: flex; justify-content: space-between; padding: 3px 0; font-size: .92rem; }
.ln b { font-weight: 800; font-variant-numeric: tabular-nums; }
.ln.total { border-top: 2px solid var(--paper-ink); margin-top: 4px; padding-top: 5px; font-weight: 900; }
.pos { color: #1c8a5f; } .neg { color: #c2334c; }
.cashrow { display: flex; gap: 8px; margin-top: 12px; }
.cashrow div { flex: 1; border-radius: 14px; padding: 8px 10px; background: #fff8; border: 1.5px solid rgba(43,42,61,.15); text-align: center; }
.cashrow small { display: block; font-size: .7rem; color: #6a6785; }
.cashrow strong { font-size: 1.1rem; font-weight: 900; }
.asset { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed rgba(43,42,61,.2); }
.asset .em { font-size: 1.6rem; }
.asset .nm { flex: 1; font-weight: 800; font-size: .92rem; line-height: 1.3; }
.asset .nm small { display: block; font-weight: 400; color: #6a6785; font-size: .72rem; }
.empty { text-align: center; color: #6a6785; padding: 18px 0; font-size: .9rem; }
.logbox { margin-top: 10px; background: var(--night2); border: 1px solid var(--line); border-radius: 18px; padding: 8px 14px; max-height: 280px; overflow-y: auto; }
.logbox li { list-style: none; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .88rem; color: var(--muted); }
.logbox li:first-child { color: var(--ivory); font-weight: 700; }
.logbox ul { margin: 0; padding: 0; }
.leave { margin-top: 18px; }

/* ---------- کارت تصمیم (پایین صفحه) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(8,9,30,.6); backdrop-filter: blur(3px); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto; border-radius: 26px 26px 0 0; padding: 0 0 calc(18px + env(safe-area-inset-bottom)); background: var(--ivory); color: var(--paper-ink); animation: rise .35s cubic-bezier(.2,1.1,.4,1); box-shadow: 0 -16px 50px #000a; }
@keyframes rise { from { transform: translateY(100%); } }
.sheet .band { background: var(--k, var(--lapis)); color: #fff; padding: 16px 18px 14px; border-radius: 26px 26px 0 0; display: flex; align-items: center; gap: 12px; }
.sheet .band .big { font-size: 2.6rem; line-height: 1; filter: drop-shadow(0 3px 4px #0005); }
.sheet .band h2 { margin: 0; font-size: 1.25rem; font-weight: 900; line-height: 1.3; }
.sheet .band small { opacity: .85; font-size: .78rem; }
.sheet .body { padding: 14px 18px 0; }
.sheet .note { font-size: .88rem; color: #4a476a; margin: 0 0 10px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.fact { border-radius: 14px; padding: 8px 10px; background: #fff9; border: 1.5px solid rgba(43,42,61,.14); }
.fact small { display: block; font-size: .7rem; color: #6a6785; }
.fact strong { font-size: 1.08rem; font-weight: 900; }
.fact.hl { grid-column: 1 / -1; background: linear-gradient(135deg, #d9f7f1, #e9fbe8); border-color: #8fdccf; }
.fact.hl strong { color: #12795f; font-size: 1.4rem; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .two { display: flex; gap: 10px; }
.actions .two .btn { flex: 1; }
.btn.paper-ghost { background: transparent; border: 1.5px solid rgba(43,42,61,.3); color: var(--paper-ink); }
.btn.loan { background: #fff; border: 1.5px dashed var(--orange); color: #a24520; }
.warn { color: #c2334c; font-size: .82rem; margin: 6px 0 0; text-align: center; min-height: 1.2em; }
.waiting { position: fixed; inset-inline: 0; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; justify-content: center; z-index: 10; pointer-events: none; }
.waiting span { background: var(--night3); border: 1px solid var(--line); border-radius: 22px; padding: 8px 18px; font-size: .88rem; box-shadow: 0 8px 24px #0008; }

/* ---------- برنده ---------- */
.win { text-align: center; }
.win .trophy { font-size: 4.5rem; animation: bob 1.4s ease-in-out infinite; }
.win h2 { font-size: 1.7rem; font-weight: 900; margin: 6px 0; color: var(--saffron); }

@media (min-width: 900px) {
  .wrap.game { max-width: 980px; display: grid; grid-template-columns: 460px 1fr; gap: 22px; align-items: start; }
  .wrap.game .chips { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.howto h2 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 900; color: var(--saffron); }
.howto ol { margin: 0; padding-inline-start: 22px; color: var(--muted); font-size: .9rem; }
.howto li { margin: 6px 0; }
.howto b { color: var(--ivory); }

/* ---------- مسیر سریع ---------- */
.trackname { text-align: center; font-size: .8rem; font-weight: 800; color: var(--muted); letter-spacing: .04em; margin-top: 2px; }
.trackname.fast { color: var(--turq); }
.wheel.fast .plate { background: radial-gradient(circle at 50% 40%, #1f4d63 0, #123049 62%, #0d2036 100%); border-color: var(--turq);
  box-shadow: 0 0 0 6px #14163a, 0 0 0 8px rgba(53,196,181,.45), 0 0 40px rgba(53,196,181,.25), 0 24px 50px #000a, inset 0 0 40px #0008; }
.wheel.fast .plate::after { border-color: rgba(53,196,181,.35); }
.wheel.fast .center { background: radial-gradient(circle at 50% 30%, #2a6a7e, #123049 70%); border-color: rgba(53,196,181,.5); }
.tile.mydream { box-shadow: 0 0 0 2px #fff, 0 0 14px 3px var(--saffron); }
.bar > i.gold { background: linear-gradient(90deg, var(--saffron), #ffd98a); }
.dreams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.dreamopt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: 16px; background: #fff9; border: 1.5px solid rgba(43,42,61,.18); color: var(--paper-ink); text-align: center; line-height: 1.35; }
.dreamopt:active { transform: scale(.97); }
.dreamopt .di { font-size: 2rem; }
.dreamopt b { font-size: .88rem; }
.dreamopt small { color: #6a6785; }
