* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background:
        radial-gradient(circle at 25% 0%, rgba(255, 196, 0, 0.14), transparent 55%),
        radial-gradient(circle at 80% 100%, rgba(120, 80, 220, 0.20), transparent 55%),
        linear-gradient(135deg, #181428 0%, #1a1a2e 60%, #14131f 100%);
    min-height: 100vh; min-height: 100dvh;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px) + 12px);
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.user-bar { margin: 0 auto 12px; }

.cf-game { max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

.cf-tabs {
    display: flex; gap: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px; padding: 5px;
}
.cf-tab {
    flex: 1; padding: 11px; border: none; border-radius: 10px;
    background: transparent; color: rgba(255,255,255,0.65);
    font-size: 15px; font-weight: 700; cursor: pointer; transition: .15s;
}
.cf-tab.active { background: linear-gradient(135deg, #ffd24a, #f7a600); color: #2a1c00; box-shadow: 0 4px 14px rgba(247,166,0,0.35); }

/* Coin stage */
.cf-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0; }
/* ── 3D coin: two faces (eagle / crown) + a gold edge cylinder for thickness ── */
.cf-coin {
    width: 150px; height: 150px;
    perspective: 850px;
    display: flex; align-items: center; justify-content: center;
}
.cf-coin-inner {
    position: relative; width: 100%; height: 100%;
    transform-style: preserve-3d;
    transform: rotateX(0deg);
    filter: drop-shadow(0 12px 16px rgba(0,0,0,0.5));
}
.cf-coin.spinning .cf-coin-inner { animation: cf-flip 1.5s cubic-bezier(.25,.7,.25,1); }
/* Tumble around the horizontal axis (rotateX) — coin flips end-over-end while
   tossed up, like a real coin. 1800deg = 5 full turns → always lands front-up. */
@keyframes cf-flip {
    0%   { transform: translateY(0)     rotateX(0deg)    scale(1);    }
    50%  { transform: translateY(-28px) rotateX(900deg)  scale(1.07); }
    100% { transform: translateY(0)     rotateX(1800deg) scale(1);    }
}
.cf-face {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: contain;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.cf-front { transform: translateZ(8px); }
.cf-back  { transform: rotateX(180deg) translateZ(8px); }
/* edge slices: stacked gold discs between the faces form the coin's body */
.cf-edge {
    position: absolute; top: 7%; left: 7%; width: 86%; height: 86%;
    border-radius: 50%;
    background:
        repeating-linear-gradient(90deg, #a9760a 0 3px, #f0c64b 3px 6px);
}
/* Outcome ring: green on win, red on loss. */
.cf-coin.win  { box-shadow: 0 0 0 5px rgba(105,219,124,0.45); border-radius: 50%; }
.cf-coin.lose { box-shadow: 0 0 0 5px rgba(226,90,90,0.4);  border-radius: 50%; }
/* Loss briefly greys the coin, then it fades back to bright gold — driven by a
   self-completing CSS animation (NOT a JS timer, which a backgrounded Telegram
   WebView can freeze and leave the coin dimmed forever). `forwards` holds the
   bright final frame even if the .dim class is never removed. */
.cf-coin-inner { transition: filter .3s ease; }
.cf-coin.dim .cf-coin-inner {
    animation: cfLossDim 1s ease forwards;
}
@keyframes cfLossDim {
    0%,60% { filter: grayscale(0.6) brightness(0.78) drop-shadow(0 12px 16px rgba(0,0,0,0.5)); }
    100%   { filter: grayscale(0)   brightness(1)    drop-shadow(0 12px 16px rgba(0,0,0,0.5)); }
}

.cf-result { min-height: 26px; font-size: 17px; font-weight: 800; text-align: center; }
.cf-result.win  { color: #7be89a; }
.cf-result.lose { color: #ff8a8a; }

.cf-panel {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px; padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
}
.cf-label { font-size: 13px; color: rgba(255,255,255,0.6); font-weight: 600; }

.cf-sides { display: flex; gap: 10px; }
.cf-side {
    flex: 1; padding: 14px; border: 2px solid rgba(255,255,255,0.14);
    border-radius: 12px; background: rgba(255,255,255,0.06);
    color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform .1s ease, background .15s, border-color .15s, opacity .15s;
}
/* Пальцем нажали — мгновенная отдача (нажата ≠ выбрана) */
.cf-side:active { transform: scale(0.95); background: rgba(255,255,255,0.13); }
/* Пока монета в воздухе: обе стороны гаснут и не кликаются… */
.cf-sides.is-flipping .cf-side { opacity: .38; pointer-events: none; transform: none; }
/* …кроме выбранной — она горит золотом и пульсирует («сейчас бросается») */
.cf-sides.is-flipping .cf-side.flipping {
    opacity: 1; border-color: #ffd24a; background: rgba(255,210,74,0.18);
    box-shadow: 0 0 0 2px rgba(255,210,74,0.4);
    animation: cfSidePulse 0.9s ease-in-out infinite;
}
@keyframes cfSidePulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255,210,74,0.4); }
    50%      { box-shadow: 0 0 0 5px rgba(255,210,74,0.65); }
}

/* Slots-style bet selector: bases 100/200/500 + a "+" step button */
.cf-bet-row { display: flex; gap: 8px; }
.cf-bet {
    flex: 1; min-width: 0; padding: 12px 4px;
    border: 2px solid rgba(255,255,255,0.1); border-radius: 10px;
    background: rgba(255,255,255,0.05); color: #fff;
    font-size: 14px; font-weight: 700; cursor: pointer; transition: .12s;
    white-space: nowrap;
}
.cf-bet.active { border-color: #ffd24a; background: rgba(255,210,74,0.16); }
.cf-bet-plus {
    flex: 0 0 auto; width: 50px; border: none; border-radius: 10px;
    background: linear-gradient(135deg, #ffd24a, #f7a600); color: #2a1c00;
    font-size: 24px; font-weight: 800; line-height: 1; cursor: pointer;
    box-shadow: 0 4px 12px rgba(247,166,0,0.32);
}
.cf-bet-plus:active { transform: scale(0.95); }
.cf-bet-plus:disabled { opacity: 0.4; box-shadow: none; cursor: default; }

.cf-action {
    width: 100%; padding: 15px; border: none; border-radius: 13px;
    background: linear-gradient(135deg, #ffd24a, #f7a600); color: #2a1c00;
    font-size: 17px; font-weight: 800; cursor: pointer; box-shadow: 0 5px 16px rgba(247,166,0,0.35);
}
.cf-action:active { transform: scale(0.98); }
.cf-action:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.cf-action--ghost { background: rgba(255,255,255,0.08); color: #fff; box-shadow: none; font-size: 15px; padding: 13px; }

.cf-hint { font-size: 12.5px; color: rgba(255,255,255,0.55); text-align: center; line-height: 1.4; margin-bottom: 6px; }

#cfOnlineIdle, #cfOnlineWaiting, #cfOnlineAccept { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.cf-spinner {
    width: 40px; height: 40px; border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.15); border-top-color: #ffd24a;
    animation: cf-rot 0.9s linear infinite;
}
@keyframes cf-rot { to { transform: rotate(360deg); } }
.cf-wait-title { font-size: 17px; font-weight: 800; text-align: center; }
.cf-wait-sub { font-size: 13.5px; color: rgba(255,255,255,0.65); text-align: center; }
.cf-link {
    width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px; padding: 10px 12px; font-size: 12.5px; word-break: break-all; text-align: center;
}
#cfInviteBox { width: 100%; display: flex; flex-direction: column; gap: 10px; }
