:root {
  --color-bg: #0d0204;
  --color-text: #ffffff;
  --color-label: #ffc356;
  --color-panel: rgba(3, 3, 3, .82);
  --color-line: rgba(255, 255, 255, .25);
  --color-cell: rgba(0, 0, 0, .5);
  --color-gold: #f5bd3d;
  --color-select: #ffd000;
  --color-badge: linear-gradient(#e6e6e6, #c9c9c9);
  --color-badge-text: #030303;
  --font-ui: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--color-bg); color: var(--color-text); font-family: var(--font-ui); user-select: none; -webkit-tap-highlight-color: transparent; }
#stage, #stage canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* UI lives in the same virtual space as the game layer; game.js sets size + transform. */
.ui { position: fixed; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.ui::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: var(--shade, 220px); background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.ui > .pill { width: 473px; height: 106px; border-radius: 58px; pointer-events: none; background: linear-gradient(90deg, transparent, rgba(0,0,0,.7) 50%, transparent); }
.ui > * { position: absolute; pointer-events: auto; transform: translate(-50%, -50%); }
.btn { border: 0; padding: 0; background: none; cursor: pointer; transition: transform .1s, filter .2s; }
.btn img { width: 100%; height: 100%; display: block; pointer-events: none; }
.btn:active { transform: translate(-50%, -50%) scale(.94); }
.btn:disabled { filter: grayscale(1) brightness(.6); cursor: default; }
.btn:focus-visible { outline: 3px solid var(--color-gold); outline-offset: 4px; border-radius: 50%; }
.btn[aria-pressed="true"] { filter: drop-shadow(0 0 14px var(--color-gold)) brightness(1.2); }
.round { width: var(--btn, 94px); height: var(--btn, 94px); }
#btn-menu { width: var(--menu-btn, 94px); height: var(--menu-btn, 94px); }
.spin { width: 300px; height: 300px; }
.spin:disabled { filter: none; }
.spin:disabled img, .spin.busy img { content: url(assets/ui/spin-disabled.png?v=3); }
.field { text-align: center; white-space: nowrap; pointer-events: none; }
.field span { display: block; font-weight: 800; font-size: var(--label, 28px); color: var(--color-label); text-transform: uppercase; }
.field b { display: block; font-weight: 800; font-size: var(--value, 32px); }

#f-bet { cursor: pointer; pointer-events: auto; color: inherit; font: inherit; }
#f-bet:active { transform: translate(-50%, -50%) scale(.97); }
#f-bet:disabled { filter: none; opacity: .7; }
/* Autospin state from Figma (spin-bttn / autospin): ring without arrow + light counter badge. */
.spin.auto img, .spin.auto:disabled img { content: url(assets/ui/spin-auto.png?v=3); }
.spin.auto { filter: none; }
.spin em { position: absolute; left: 50%; top: 50%; width: 36.2%; aspect-ratio: 1; transform: translate(-50%, -50%); display: grid; place-items: center;
  border: 2px solid var(--color-text); border-radius: 4%; background: var(--color-badge); box-shadow: 0 1px 4px rgba(0,0,0,.4);
  font: 700 calc(var(--spin-size, 300px) * .147) var(--font-ui); font-style: normal; color: var(--color-badge-text); }

/* Popups: built at Figma size (318px wide) and scaled with --pop-scale per layout. */
.ui > .pop-backdrop { inset: 0; transform: none; background: rgba(0,0,0,.45); }
.ui > .pop { left: 50%; top: 50%; width: 318px; transform: translate(-50%, -50%) scale(var(--pop-scale, 1.7)); background: linear-gradient(rgba(255,255,255,.12), rgba(255,255,255,0) 40%), var(--color-panel); border: 1px solid var(--color-line); border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.6); color: var(--color-text); }
.pop header { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--color-line); }
.pop h2 { margin: 0; font: 700 16px var(--font-ui); color: var(--color-label); text-transform: uppercase; }
.pop-close { background: none; border: 0; color: var(--color-text); font: 400 24px/1 var(--font-ui); cursor: pointer; width: 24px; height: 24px; padding: 0; }
.pop-body { padding: 16px; display: grid; gap: 8px; }
.pop-body + .pop-body { border-top: 1px solid var(--color-line); }
.pop-body p { margin: 4px 0 0; font: 400 14px var(--font-ui); text-transform: uppercase; }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.chip { height: 31px; border-radius: 8px; border: 1px solid rgba(255,255,255,.08); background: rgba(0,0,0,.5); color: var(--color-text); font: 700 14px var(--font-ui); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--color-select); border-color: var(--color-select); color: #000; box-shadow: inset 0 0 8px rgba(0,0,0,.25); }
.chip:disabled { opacity: .35; cursor: default; }
.adv-toggle { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; color: var(--color-select); font: 700 16px var(--font-ui); cursor: pointer; text-transform: uppercase; }
.adv-toggle i { font-style: normal; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #fff; color: #000; font-size: 13px; transition: transform .2s; }
.adv-toggle[aria-expanded="true"] i { transform: rotate(180deg); }
#adv-body { display: grid; gap: 8px; }
.pop footer { padding: 12px 16px 16px; border-top: 1px solid var(--color-line); }
.cta { width: 100%; height: 40px; border-radius: 7px; border: 2px solid rgba(255,255,255,.35); background: radial-gradient(120% 90% at 50% 100%, #000 30%, transparent 70%), linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0)), rgba(0,0,0,.4); color: var(--color-text); font: 700 16px var(--font-ui); text-transform: uppercase; cursor: pointer; }
.cta:active { transform: scale(.98); }

.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); background: var(--color-panel); border: 1px solid var(--color-line); border-radius: 10px; padding: 12px 20px; font-weight: 700; z-index: 20; }

.loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 24px; z-index: 30; transition: opacity .4s;
  background: linear-gradient(rgba(10,2,4,.45), rgba(10,2,4,.8)), var(--load-bg, none) center / cover no-repeat, var(--color-bg); }
.loading img { width: min(60vw, 420px); }
.loading .bar { width: min(60vw, 360px); height: 8px; border-radius: 8px; background: var(--color-line); overflow: hidden; }
.loading i { display: block; height: 100%; width: 0; background: var(--color-gold); transition: width .2s; }
.loading p { margin: 0; font-weight: 700; color: var(--color-label); min-height: 1.2em; text-align: center; max-width: 80vw; }
.loading.done { opacity: 0; pointer-events: none; }

.menu { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 25; padding: 16px; }
.menu-panel { width: min(1100px, 100%); height: min(780px, 100%); display: flex; flex-direction: column; background: var(--color-panel); border: 1px solid var(--color-line); border-radius: 12px; overflow: hidden; }
.menu header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--color-line); gap: 12px; }
.menu nav { display: flex; gap: 8px; flex-wrap: nowrap; min-width: 0; }
.tab { font: 700 15px var(--font-ui); color: var(--color-text); background: var(--color-cell); border: 1px solid var(--color-line); border-radius: 8px; padding: 10px 16px; cursor: pointer; text-transform: uppercase; }
.tab.active { color: #111; background: var(--color-label); border-color: var(--color-label); }
.close { font: 400 34px/1 var(--font-ui); color: var(--color-text); background: none; border: 0; cursor: pointer; width: 44px; height: 44px; }
.tab-body { flex: 1; min-height: 0; overflow: auto; padding: 24px; }
@media (max-width: 560px) { .tab { padding: 10px 12px; font-size: 13px; } .menu header { padding: 12px 14px; } }
.tab-body h3 { color: var(--color-label); margin: 24px 0 8px; font-size: 18px; }
.tab-body h3:first-child { margin-top: 0; }
.tab-body p { margin: 0 0 8px; line-height: 1.5; opacity: .88; }
.pay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.pay-card { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 8px; background: var(--color-cell); border: 1px solid rgba(255,255,255,.12); }
.pay-card img { width: 84px; height: 84px; object-fit: contain; flex: none; }
.pay-card dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 2px 12px; font-weight: 700; }
.pay-card dt { color: var(--color-label); }
.pay-card dd { margin: 0; }
.pay-card small { grid-column: 1 / -1; color: var(--color-label); font-weight: 500; }
.lines-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.line-card { text-align: center; font-weight: 700; color: var(--color-label); }
.line-card .cells { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; padding: 6px; border: 1px solid rgba(245,189,61,.6); border-radius: 8px; margin-top: 6px; }
.line-card .cells i { aspect-ratio: 1; border-radius: 3px; background: #0a0c14; }
.line-card .cells i.on { background: var(--color-gold); }

/* ---------- Buy Bonus (Figma section "Royal slots — Buy Bonus") ---------- */
/* Round button from Figma set 60:10686: Default / Variant2 (hover, also armed) / Variant3 (pressed) / Variant4 (disabled). */
.buy:hover img, .buy.armed img { content: url(assets/ui/buy-hover.png); }
.buy:active img { content: url(assets/ui/buy-pressed.png); }
.buy:disabled { filter: none; }
.buy:disabled img { content: url(assets/ui/buy-disabled.png); }
.buy.armed { filter: drop-shadow(0 0 18px rgba(255, 196, 60, .8)); }

/* Buy Bonus popup = Figma "popup / buy-bonus" Size=Desktop (603×797), scaled by --bb-scale (mobile variant is the same layout ×0.625). */
.ui > #pop-buy { width: 603px; min-height: 797px; box-sizing: border-box; padding: 35px 13px 36px; display: flex; flex-direction: column;
  background: url(assets/img/bb/popup-frame.png) center / 100% 100% no-repeat; border: 0; border-radius: 0; box-shadow: none;
  transform: translate(-50%, -50%) scale(var(--bb-scale, 1)); }
#pop-buy header { position: relative; justify-content: center; padding: 24px; border: 0; }
#pop-buy h2 { font: 700 40px/1.2 var(--font-ui); color: #ffd000; }
#pop-buy .pop-close { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; font-size: 48px; }
#pop-buy .pop-body { padding: 24px; gap: 12px; }
#pop-buy .pop-body + .pop-body { border-top: 0; padding: 21px 24px; }
#pop-buy .bb-bet { font-size: 21px; }
#pop-buy .bb-tiers { gap: 12px; }
#pop-buy .tier { height: 104px; gap: 18px; padding: 0 18px; border-radius: 12px; border: 2px solid rgba(255,255,255,.08); background: rgba(0,0,0,.5); }
#pop-buy .tier[aria-pressed="true"] { border: 3px solid #ffd000; background: rgba(255,208,0,.14); padding: 0 17px; }
#pop-buy .tier img { width: 94px; height: 100px; object-fit: contain; flex: none; }
#pop-buy .tier .tt { gap: 3px; }
#pop-buy .tier .tt b { font: 700 22.5px var(--font-ui); }
#pop-buy .tier small { font-size: 18px; }
#pop-buy .tier .tp b { font: 800 27px var(--font-ui); color: #ffd000; }
#pop-buy .tier .tp small { font-size: 16.5px; opacity: .6; }
#pop-buy .bb-gw { gap: 18px; }
#pop-buy .bb-gw i { width: 66px; height: 36px; border-radius: 18px; }
#pop-buy .bb-gw i::after { left: 5px; top: 5px; width: 26px; height: 26px; }
#pop-buy .bb-gw[aria-checked="true"] i::after { transform: translateX(30px); }
#pop-buy .bb-gw b { font-size: 24px; color: #ffd000; }
#pop-buy .bb-gw small { font-size: 18px; }
#pop-buy footer { margin-top: auto; padding: 24px; border: 0; }
#pop-buy .cta { height: 61px; border-radius: 14px; border: 2.5px solid #256e01; color: #fff; font: 700 24px var(--font-ui);
  background: radial-gradient(60% 80% at 50% 45%, rgba(210,255,140,.25), transparent),
    linear-gradient(rgba(255,255,255,.35) 4%, rgba(255,255,255,.08) 40%, transparent 46%),
    linear-gradient(#54b834, #289622 46%, #126e1a 54%, #0a4e12);
  text-shadow: 0 2px 0 #084610, 0 2px 4px rgba(0,0,0,.5);
  box-shadow: 0 7px 0 #0a4010, 0 12px 14px rgba(0,0,0,.55), 0 0 20px rgba(140,255,90,.3), inset 0 2px 1px rgba(200,255,170,.5), inset 0 -6px 4px rgba(6,60,14,.9); }
#pop-buy .cta:active { transform: translateY(4px); box-shadow: 0 3px 0 #0a4010, 0 6px 10px rgba(0,0,0,.5), inset 0 2px 1px rgba(200,255,170,.5), inset 0 -6px 4px rgba(6,60,14,.9); }
#pop-buy .bb-note { margin-top: 12px; font-size: 16.5px; }
#pop-buy .bb-link { font-size: 18px; }
.ui > .bb-strip { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 20px; border-radius: 40px; white-space: nowrap;
  background: rgba(0,0,0,.72); border: 2px solid var(--color-select); font: 700 calc(var(--label) * .68) var(--font-ui); color: var(--color-text); }
.bb-strip b { color: var(--color-select); font-weight: 800; text-transform: uppercase; }
.bb-strip button { width: 1.6em; height: 1.6em; border: 0; border-radius: 50%; background: rgba(255,255,255,.15); color: var(--color-text); font: inherit; line-height: 1; cursor: pointer; }
.bb-bet { display: flex; justify-content: space-between; font: 400 14px var(--font-ui); text-transform: uppercase; }
.bb-bet b { color: var(--color-select); font-weight: 700; }
.bb-tiers { display: grid; gap: 8px; }
.tier { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.08); background: rgba(0,0,0,.5); color: var(--color-text); text-align: left; cursor: pointer; font-family: var(--font-ui); }
.tier[aria-pressed="true"] { border: 2px solid var(--color-select); background: rgba(255,208,0,.14); padding: 9px 11px; }
.tier .mini { display: flex; gap: 3px; flex: none; }
.tier .mini i { width: 9px; height: 26px; border-radius: 3px; background: rgba(255,255,255,.14); }
.tier .mini i.w { background: linear-gradient(#ffeca0, #d6962a 50%, #784608); }
.tier .tt { flex: 1; display: grid; gap: 2px; }
.tier .tt b { font: 700 14px var(--font-ui); text-transform: uppercase; }
.tier small { font: 400 11px var(--font-ui); opacity: .7; }
.tier .tp { display: grid; justify-items: end; }
.tier .tp b { font: 800 17px var(--font-ui); color: var(--color-select); }
.bb-gw { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: 0; padding: 0; color: var(--color-text); text-align: left; cursor: pointer; font-family: var(--font-ui); }
.bb-gw i { flex: none; position: relative; width: 44px; height: 24px; border-radius: 12px; background: rgba(255,255,255,.2); transition: background .2s; }
.bb-gw i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.bb-gw[aria-checked="true"] i { background: var(--color-select); }
.bb-gw[aria-checked="true"] i::after { transform: translateX(20px); }
.bb-gw span { display: grid; gap: 2px; }
.bb-gw b { font: 700 16px var(--font-ui); color: var(--color-select); text-transform: uppercase; }
.bb-gw small { font: 400 12px var(--font-ui); opacity: .7; }
.cta:disabled { opacity: .45; cursor: default; }
.bb-link { display: block; margin: 10px auto 0; background: none; border: 0; color: var(--color-select); font: 700 14px var(--font-ui); text-transform: uppercase; cursor: pointer; }
.bb-note { margin: 8px 0 0; text-align: center; font: 400 11px var(--font-ui); opacity: .6; }

.ui > .apl { pointer-events: none; object-fit: contain; }
#pop-buy .bb-gw[aria-checked="true"] i { background: linear-gradient(#54b834, #289622 46%, #126e1a 54%, #0a4e12); box-shadow: inset 0 0 0 2px #256e01; }
.menu-audio { display: flex; gap: 28px; justify-content: center; padding: 14px 20px; border-top: 1px solid var(--color-line); }
.tg { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; color: var(--color-text); font: 700 15px var(--font-ui); text-transform: uppercase; cursor: pointer; }
.tg i { position: relative; width: 44px; height: 24px; border-radius: 12px; background: rgba(255,255,255,.2); transition: background .2s; }
.tg i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tg[aria-checked="true"] i { background: linear-gradient(#54b834, #289622 46%, #126e1a 54%, #0a4e12); }
.tg[aria-checked="true"] i::after { transform: translateX(20px); }
.ui[data-layout="port"] > .bb-strip { font-size: 34px; gap: 18px; padding: 14px 14px 14px 32px; border-width: 3px; border-radius: 60px; }

/* Farsi: right-to-left text in popups, menu and toasts (the HUD keeps its fixed layout) */
html[data-dir="rtl"] .pop, html[data-dir="rtl"] #menu, html[data-dir="rtl"] #toast { direction: rtl; }
