/* ============================================================
   COIN — единый дизайн-код (design system).
   Премиум-дарк, без backdrop-filter (плавно на слабых устройствах).
   Только transform/opacity в анимациях. Иконки — SVG.
   ============================================================ */

/* ── 1. Токены ─────────────────────────────────────────────── */
:root {
  /* фон / поверхности */
  --ink:       #08090e;
  --surface:   #14151d;
  --surface-2: #1b1d28;
  --surface-3: #232533;
  --hairline:  rgba(255,255,255,.075);
  --hairline-2:rgba(255,255,255,.13);

  /* текст */
  --text:  #f4f6fc;
  --dim:   #9096ac;
  --faint: rgba(233,238,255,.30);

  /* бренд / акценты */
  --gold-1: #ffe7a0; --gold-2: #ffce5e; --gold-3: #c98a22; --gold-ink: #5e3f04;
  --blue-1: #5cc6ff; --blue-2: #0a84ff;
  --red-1:  #ff7a6e; --red-2:  #ff453a;
  --violet-1: #d6a8ff; --violet-2: #bf5af2;
  --green: #30d158;

  /* семантика сторон */
  --heads: var(--blue-2);  --heads-1: var(--blue-1);
  --edge:  var(--red-2);   --edge-1:  var(--red-1);
  --tails: var(--violet-2);--tails-1: var(--violet-1);

  /* радиусы */
  --r-sm: 12px; --r-md: 16px; --r-lg: 22px; --r-pill: 999px;

  /* отступы (4-pt ритм) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  /* тени / возвышение */
  --e1: 0 6px 16px -8px rgba(0,0,0,.55);
  --e2: 0 12px 30px -12px rgba(0,0,0,.65);
  --e3: 0 18px 44px -14px rgba(0,0,0,.7);

  /* мотион */
  --dur-1: .16s; --dur-2: .28s; --dur-3: .45s;
  --spring: cubic-bezier(.34, 1.4, .5, 1);
  --ease:   cubic-bezier(.22, .8, .3, 1);
}

/* ── 2. База ───────────────────────────────────────────────── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Manrope", system-ui, sans-serif;
  color: var(--text); background: var(--ink);
  overscroll-behavior: none; -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body { max-width: 540px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) var(--s4) calc(env(safe-area-inset-bottom) + 130px); }

.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(58% 40% at 50% -6%, #1c2348 0%, #0d101c 48%, var(--ink) 82%),
    radial-gradient(44% 32% at 88% 2%, rgba(191,90,242,.13), transparent 60%);
}

svg { display: block; }
.ico { width: 18px; height: 18px; }

/* ── 3. Топ-бар + бренд ───────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.pill {
  display: inline-flex; align-items: center; gap: var(--s2);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-pill);
  padding: 9px 14px; font: inherit; color: var(--text); box-shadow: var(--e1);
}
.brand { font-weight: 800; letter-spacing: .14em; padding-left: 11px; }
.brand .logo { width: 24px; height: 24px; }
.balance { cursor: pointer; font-weight: 800; transition: transform var(--dur-2) var(--spring), box-shadow var(--dur-2); }
.balance:active { transform: scale(.95); }
.balance__val { font-variant-numeric: tabular-nums; }
.balance__plus { display: grid; place-items: center; width: 21px; height: 21px; margin-left: 2px; background: var(--blue-2); border-radius: 50%; font-size: 15px; color: #fff; font-weight: 700; }
.balance.flash { box-shadow: 0 0 0 2px rgba(255,255,255,.5), 0 0 18px rgba(255,255,255,.22); }
.gem { width: 15px; height: 15px; }
.gem--sm { width: 14px; height: 14px; }

/* ── 4. Вью / переходы ────────────────────────────────────── */
.view { display: none; animation: viewIn var(--dur-3) var(--ease); }
.view--active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── 5. Статус-строка ─────────────────────────────────────── */
.status { display: flex; justify-content: space-between; align-items: center; margin: var(--s4) 2px var(--s3); font-size: 12px; }
.status__fair { display: inline-flex; align-items: center; gap: 5px; color: var(--green); font-weight: 700; }
.status__fair .ico { width: 14px; height: 14px; }
.status__game { color: var(--dim); font-variant-numeric: tabular-nums; }

/* ── 6. Стрик ─────────────────────────────────────────────── */
.streak { display: flex; gap: 7px; overflow: hidden; margin-bottom: var(--s3); min-height: 30px; }
.streak__dot { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: #fff; box-shadow: var(--e1); animation: dropIn var(--dur-3) var(--spring); }
.streak__dot .ico { width: 16px; height: 16px; }
.streak__dot.heads { background: linear-gradient(180deg, var(--heads-1), var(--heads)); }
.streak__dot.edge  { background: linear-gradient(180deg, var(--edge-1), var(--edge)); }
.streak__dot.tails { background: linear-gradient(180deg, var(--tails-1), var(--tails)); }
@keyframes dropIn { from { opacity: 0; transform: translateX(-10px) scale(.6); } to { opacity: 1; transform: none; } }

/* ── 7. Талли ─────────────────────────────────────────────── */
.tally { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--s2); margin-bottom: 6px; }
.tally__col { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 11px 6px; text-align: center; }
.tally__col b { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tally__col span { font-size: 11px; color: var(--dim); }
.tally__col--heads b { color: var(--heads-1); }
.tally__col--edge b  { color: var(--edge-1); }
.tally__col--tails b { color: var(--tails-1); }

/* ── 8. Монета (физика — в app.js через WAAPI) ───────────── */
.coin-stage { position: relative; height: 248px; display: flex; align-items: center; justify-content: center; perspective: 1100px; }
.coin-glow { position: absolute; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(50% 50%, rgba(255,206,94,.13), transparent 70%); opacity: 0; transition: opacity var(--dur-2), background var(--dur-2); }
.coin-glow.show { opacity: 1; }
.coin-shadow { position: absolute; bottom: 26px; width: 124px; height: 18px; border-radius: 50%; background: radial-gradient(50% 50%, rgba(0,0,0,.5), transparent 72%); }
.coin-wrap { position: relative; width: 168px; height: 168px; transform-style: preserve-3d; will-change: transform; }
.coin { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(-15deg); will-change: transform; }
.coin__face {
  position: absolute; inset: 0; border-radius: 50%; backface-visibility: hidden; overflow: hidden;
  display: grid; place-items: center;
  background: radial-gradient(70% 70% at 36% 28%, #fff7da 0%, var(--gold-2) 26%, #f0a93a 60%, var(--gold-3) 100%);
  box-shadow: inset 0 0 0 7px rgba(255,255,255,.26), inset 0 0 0 12px rgba(150,98,20,.5),
    inset 0 -16px 30px rgba(110,70,10,.5), inset 0 16px 24px rgba(255,255,255,.5);
}
.coin__face::before { content: ""; position: absolute; top: -42%; left: -28%; width: 64%; height: 184%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent); transform: rotate(20deg); }
.coin__emblem { width: 88px; height: 88px; position: relative; }
.coin__emblem.heads { color: var(--gold-ink); filter: drop-shadow(0 1px 0 rgba(255,255,255,.4)); }
.coin__face--heads { transform: translateZ(11px); }
.coin__face--tails { transform: rotateX(180deg) translateZ(11px); }
.coin__edge { position: absolute; left: 50%; top: 50%; width: 168px; height: 20px; transform: translate(-50%,-50%) rotateX(90deg); border-radius: 10px; background: repeating-linear-gradient(90deg, #9a6516 0 3px, #ffd874 3px 6px); box-shadow: inset 0 6px 8px rgba(255,255,255,.4), inset 0 -6px 8px rgba(70,44,5,.7); }
.result { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: 22px; font-weight: 800; opacity: 0; transform: translateY(8px); transition: var(--dur-2) var(--spring); }
.result.show { opacity: 1; transform: none; }
.result.win { color: var(--green); }
.result.lose { color: var(--red-1); }

/* ── 9. Ставка ────────────────────────────────────────────── */
.bet { display: flex; gap: var(--s3); margin-top: var(--s1); }
.bet__step { width: 54px; border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--surface); color: var(--text); font-size: 24px; font-weight: 600; cursor: pointer; transition: transform var(--dur-1) var(--spring); }
.bet__step:active { transform: scale(.9); }
.bet__field { flex: 1; display: flex; align-items: center; justify-content: center; gap: var(--s2); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); }
.bet__field input { width: 66%; text-align: center; background: none; border: none; outline: none; color: var(--text); font: 800 24px -apple-system, "Manrope"; font-variant-numeric: tabular-nums; }
.bet__field input::-webkit-outer-spin-button, .bet__field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s2); }
.chip { padding: 11px 0; border: 1px solid var(--hairline); border-radius: var(--r-sm); background: var(--surface); color: var(--dim); font: 800 13px -apple-system, "Manrope"; letter-spacing: .04em; cursor: pointer; transition: transform var(--dur-1) var(--spring), color var(--dur-2); }
.chip:active { transform: scale(.94); color: var(--text); }

/* подсказка «1 тап = бросок» */
.hint { margin: var(--s4) 0 var(--s2); text-align: center; font-size: 12px; color: var(--faint); font-weight: 600; }

/* ── 10. Кнопки-ставки ────────────────────────────────────── */
.betbtns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s3); }
.betbtn { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 15px 6px; border: none; border-radius: 18px; cursor: pointer; color: #fff; font: inherit; position: relative; overflow: hidden; box-shadow: inset 0 1px 0 rgba(255,255,255,.3), var(--e2); transition: transform var(--dur-1) var(--spring), filter var(--dur-2); }
.betbtn::after { content: ""; position: absolute; inset: 0 0 55% 0; background: linear-gradient(180deg, rgba(255,255,255,.2), transparent); pointer-events: none; }
.betbtn:active { transform: scale(.95); }
.betbtn:disabled { filter: grayscale(.45) brightness(.72); }
.betbtn .ico { width: 22px; height: 22px; }
.betbtn__top { font-weight: 800; font-size: 13px; }
.betbtn__mult { font-weight: 800; font-size: 13px; opacity: .92; font-variant-numeric: tabular-nums; }
.betbtn--heads { background: linear-gradient(180deg, var(--heads-1), var(--heads)); }
.betbtn--edge  { background: linear-gradient(180deg, var(--edge-1), var(--edge)); }
.betbtn--tails { background: linear-gradient(180deg, var(--tails-1), var(--tails)); }

/* ── 11. Карточки / история ───────────────────────────────── */
.card { margin-top: var(--s4); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: var(--s4); }
.card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s3); font-size: 15px; }
.card__head b { font-weight: 800; }
.card__head span { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); max-height: 300px; overflow-y: auto; }
.plist:empty::after { content: "Сделай первый бросок"; color: var(--faint); font-size: 13px; }
.prow { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); animation: rowIn var(--dur-2) var(--spring); }
@keyframes rowIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.prow__av { width: 34px; height: 34px; border-radius: 11px; flex: 0 0 auto; display: grid; place-items: center; color: #fff; }
.prow__av .ico { width: 18px; height: 18px; }
.prow__mid { flex: 1; min-width: 0; }
.prow__name { font-weight: 700; font-size: 14px; }
.prow__sub { font-size: 12px; color: var(--dim); }
.prow__sub b { font-weight: 800; color: var(--text); }
.prow__pay { font-weight: 800; font-variant-numeric: tabular-nums; }
.prow__pay.win { color: var(--green); }
.prow__pay.lose { color: var(--faint); }
.c-heads { color: var(--heads-1); } .c-edge { color: var(--edge-1); } .c-tails { color: var(--tails-1); }
.bg-heads { background: linear-gradient(180deg, var(--heads-1), var(--heads)); }
.bg-edge  { background: linear-gradient(180deg, var(--edge-1), var(--edge)); }
.bg-tails { background: linear-gradient(180deg, var(--tails-1), var(--tails)); }

/* ── 12. Скоро ────────────────────────────────────────────── */
.soon { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s4); }
.soon__tile { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--hairline); border-radius: var(--r-lg); background: var(--surface); opacity: .68; }
.soon__tile .ico { width: 24px; height: 24px; color: var(--dim); }
.soon__tile b { font-size: 14px; }
.soon__tile span { position: absolute; top: 8px; right: 10px; font-size: 9px; font-weight: 800; letter-spacing: .08em; color: var(--faint); }

/* ── 13. Честность ────────────────────────────────────────── */
.fair__lead { font-size: 14px; color: var(--dim); line-height: 1.55; margin: var(--s4) 0; }
.fair__field { margin-bottom: var(--s3); }
.fair__field label { display: block; font-size: 11px; color: var(--faint); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .07em; }
.fair__field code { display: block; font: 12px/1.4 ui-monospace, monospace; word-break: break-all; color: var(--blue-1); background: #0d0e14; padding: 10px 12px; border-radius: 11px; }
.btn-ghost { width: 100%; margin-top: var(--s1); padding: 14px; border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: 800 13px -apple-system, "Manrope"; cursor: pointer; transition: transform var(--dur-1) var(--spring); }
.btn-ghost:active { transform: scale(.98); }
.fair__reveal { margin-top: var(--s3); font-size: 12px; color: var(--green); word-break: break-all; }

/* ── 14. Нижняя навигация (плавающий док) ─────────────────── */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 14px); display: flex; gap: 6px; padding: 7px; border-radius: var(--r-pill); background: rgba(20,21,29,.97); border: 1px solid var(--hairline); box-shadow: var(--e3); z-index: 30; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 22px; border: none; border-radius: var(--r-pill); background: transparent; color: var(--dim); font: 700 11px -apple-system, "Manrope"; cursor: pointer; transition: transform var(--dur-1) var(--spring), background var(--dur-2), color var(--dur-2); }
.tab .ico { width: 20px; height: 20px; }
.tab:active { transform: scale(.92); }
.tab--active { color: #fff; background: var(--surface-3); }

/* ── 15. Тост ─────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #20222e; border: 1px solid var(--hairline); color: var(--text); padding: 12px 18px; border-radius: var(--r-md); font-size: 14px; font-weight: 700; z-index: 60; transition: var(--dur-2) var(--spring); max-width: 90%; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--red-2); color: #ffd0cc; }

/* ── 16. Эффекты ──────────────────────────────────────────── */
.spark { position: fixed; width: 9px; height: 9px; border-radius: 2px; pointer-events: none; z-index: 50; will-change: transform, opacity; }

/* множитель-всплеск при выигрыше */
.multipop { position: fixed; left: 50%; top: 30%; transform: translate(-50%,-50%) scale(.4); opacity: 0; font-size: 44px; font-weight: 800; color: var(--gold-2); text-shadow: 0 4px 24px rgba(255,206,94,.5); pointer-events: none; z-index: 55; }

/* ── 17. Большая CTA-кнопка ───────────────────────────────── */
.cta { width: 100%; margin-top: var(--s4); padding: 17px; border: none; border-radius: 18px; color: #fff; font: 800 16px -apple-system, "Manrope"; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.3), var(--e2); transition: transform var(--dur-1) var(--spring), filter var(--dur-2); }
.cta:active { transform: scale(.98); }
.cta:disabled { filter: grayscale(.4) brightness(.72); }
.cta--crash { background: linear-gradient(180deg, var(--blue-1), var(--violet-2)); }
.cta--mines { background: linear-gradient(180deg, #4be0a0, #18a673); }
.cta--cash  { background: linear-gradient(180deg, var(--gold-1), var(--gold-3)); color: #4a3204; }

/* ── 18. Ракета ───────────────────────────────────────────── */
.crash-stage { position: relative; height: 256px; margin-top: var(--s3); border-radius: var(--r-lg); overflow: hidden; background: radial-gradient(120% 80% at 20% 100%, #161a2e 0%, #0c0e16 70%); border: 1px solid var(--hairline); }
.crash-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 30px 30px; mask-image: linear-gradient(0deg, #000, transparent 90%); }
.crash-mult { position: absolute; top: 38%; left: 0; right: 0; text-align: center; font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; transition: color .2s; text-shadow: 0 6px 30px rgba(0,0,0,.5); }
.crash-mult.win { color: var(--green); } .crash-mult.lose { color: var(--red-2); }
.crash-trail { position: absolute; inset: 0; width: 100%; height: 100%; }
.crash-rocket { position: absolute; left: 10%; bottom: 14%; width: 40px; height: 40px; will-change: transform; }
.crash-rocket svg { width: 100%; height: 100%; transform: rotate(38deg); }
.crash-rocket.boom svg { animation: boom .4s var(--ease) forwards; }
@keyframes boom { to { transform: rotate(38deg) scale(1.8); opacity: 0; } }
.crash-targets { display: grid; grid-template-columns: repeat(5,1fr); gap: var(--s2); margin-top: var(--s3); }
.ctarget { padding: 11px 0; border: 1px solid var(--hairline); border-radius: var(--r-sm); background: var(--surface); color: var(--dim); font: 800 13px -apple-system, "Manrope"; cursor: pointer; font-variant-numeric: tabular-nums; transition: transform var(--dur-1) var(--spring), border-color .2s, color .2s; }
.ctarget:active { transform: scale(.94); }
.ctarget.sel { color: #fff; border-color: var(--violet-2); background: linear-gradient(180deg, rgba(191,90,242,.28), rgba(10,132,255,.12)); }

/* ── 19. Минёр ────────────────────────────────────────────── */
.mines-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: var(--s2); margin-top: var(--s3); }
.mcell { aspect-ratio: 1; border: 1px solid var(--hairline); border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; cursor: pointer; transition: transform var(--dur-1) var(--spring), background .2s; }
.mcell .ico { width: 22px; height: 22px; opacity: 0; transform: scale(.4); transition: var(--dur-2) var(--spring); }
.mcell:active { transform: scale(.93); }
.mcell.idle { opacity: .5; cursor: default; }
.mcell.safe { background: linear-gradient(180deg, rgba(48,209,88,.3), rgba(24,166,115,.12)); border-color: rgba(48,209,88,.5); }
.mcell.safe .ico { opacity: 1; transform: none; color: var(--green); }
.mcell.bomb { background: linear-gradient(180deg, var(--red-1), var(--red-2)); border-color: transparent; }
.mcell.bomb .ico { opacity: 1; transform: none; color: #fff; }
.mcell.dim { opacity: .35; }
.mines-meta { display: flex; justify-content: space-between; margin-top: var(--s3); font-weight: 800; font-variant-numeric: tabular-nums; }
.mines-meta #minesMult { color: var(--green); font-size: 18px; }
.mines-meta #minesNext { color: var(--dim); font-size: 13px; align-self: center; }
.mines-opts { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--s2); margin-top: var(--s3); }
.mopt { padding: 11px 0; border: 1px solid var(--hairline); border-radius: var(--r-sm); background: var(--surface); color: var(--dim); font: 800 13px -apple-system, "Manrope"; cursor: pointer; transition: transform var(--dur-1) var(--spring), color .2s, border-color .2s; }
.mopt:active { transform: scale(.94); }
.mopt.sel { color: #fff; border-color: #18a673; background: linear-gradient(180deg, rgba(75,224,160,.26), rgba(24,166,115,.1)); }

/* история — общий блок + цвета новых игр */
.history-card { margin-top: var(--s5); }
.bg-crash { background: linear-gradient(180deg, var(--blue-1), var(--violet-2)); }
.bg-mines { background: linear-gradient(180deg, #4be0a0, #18a673); }
.c-crash { color: var(--violet-1); } .c-mines { color: #4be0a0; }

/* уважение к prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .05ms !important; }
}
