/* ==========================================================================
   Sky Crash — game-layer styles.
   Additive only: everything here layers on top of style.css, which is untouched.
   ========================================================================== */

/* ---- Canvas fills the play column ---------------------------------------- */
.app {
    position: relative;
}

.app canvas#game-canvas {
    pointer-events: none;
}

/* ---- Logo (wordmark drawn as inline SVG data) ----------------------------- */
.logo {
    object-fit: contain;
    border: 0;
}

/* ---- Avatars --------------------------------------------------------------
   img/avatars.webp is a 5x5 sprite sheet; style.css already positions each
   .avatar-N cell (background-size 500%), it only lacked the image.         */
.avatar {
    border-radius: 50%;
    background-image: url("img/avatars.webp");
    background-repeat: no-repeat;
    background-size: 500% 500%;
    background-color: #2b2b32;
}

/* ---- Bet button states ----------------------------------------------------
   Button carries exactly one of: place-bet | cancel-bet | cash-out | disable.
   The matching child div (place-bet-div, cancel-bet-div, …) is revealed.      */
.btn-bet.cancel-bet .cancel-bet-div,
.btn-bet.cash-out .cash-out-div,
.btn-bet.disable .disable-div {
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
    visibility: visible;
    transition-delay: 0s;
}

.btn-bet.cancel-bet {
    background: var(--Red-Red-gradient-base);
}

.btn-bet.cancel-bet:hover {
    background: var(--Red-Red-gradient-dark);
}

.btn-bet.cancel-bet:active {
    background: var(--Red-Red-gradient-light);
}

.btn-bet.cash-out {
    background: var(--Green-Green-gradient-base);
    overflow: hidden;
}

.btn-bet.cash-out:hover {
    background: var(--Green-Green-gradient-dark);
}

.btn-bet.cash-out:active {
    background: var(--Green-Green-gradient-light);
}

.btn-bet.disable {
    background: var(--Primary-Primary-gradient-base);
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.btn-bet.cancel-bet .btn-bet__value,
.btn-bet.cash-out .btn-bet__value {
    color: var(--Base-Base-white);
    font-variant-numeric: tabular-nums;
}

.btn-bet.cancel-bet .btn-bet__label,
.btn-bet.cash-out .btn-bet__label {
    color: rgba(255, 255, 255, 0.75);
}

/* auto-cashout progress inside the green button */
.btn-bet.cash-out .btn-bet__auto-collect-fill {
    display: block;
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: rgba(255, 255, 255, 0.18);
    border-radius: inherit;
    z-index: 2;
    pointer-events: none;
    opacity: 1;
    visibility: visible;
    transform: none;
}

.btn-bet.cash-out .btn-bet__auto-collect:not([hidden]),
.btn-bet .btn-bet__auto-collect:not([hidden]) {
    display: block;
    font-size: var(--font-size-text-xs);
    line-height: var(--line-height-text-xs);
}

/* the card dims its inputs while a bet is live */
.bet-card.is-locked .bet-input,
.bet-card.is-locked .bet-chips,
.bet-card.is-locked .collect-input,
.bet-card.is-locked .auto-row {
    opacity: 0.45;
    pointer-events: none;
}

/* autoplay pressed */
.btn-autoplay[aria-pressed="true"] {
    color: var(--Primary-Primary-base);
}

.btn-autoplay[aria-pressed="true"] svg.icon {
    animation: sc-spin 2.4s linear infinite;
}

@keyframes sc-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Menu button: hamburger turns into the close (X) icon while the menu is open */
[data-menu-toggle] {
    position: relative;
}

[data-menu-toggle][aria-expanded="true"] .icon-menu {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

[data-menu-toggle][aria-expanded="true"] .icon-close {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

/* ---- Modal open state ----------------------------------------------------- */
.game-modal.is-open {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.game-modal.is-open .game-modal__panel {
    opacity: 1;
    transform: none;
}

/* ---- Sidebar collapse ----------------------------------------------------- */
.app.is-side-hidden {
    grid-template-columns: minmax(0, 1fr) 0;
}

.app.is-side-hidden .side {
    visibility: hidden;
    overflow: hidden;
}

/* ---- HUD colouring while flying / crashed --------------------------------- */
.stage-hud.is-crashed .stage-hud__multiplier-row {
    color: var(--Red-base) !important;
}

.stage-hud.is-crashed .stage-hud__flew {
    color: var(--Red-Red-light);
}

/* Animations off (static pattern backdrop): no jet to make room for, so the HUD (countdown /
   multiplier) and the bets pill move up to the middle of the stage. game.js measures the
   distance into --static-hud-lift; `translate` composes with style.css's translateX(-50%). */
.stage-hud,
.play-bets {
    transition: translate 0.3s ease;
}

.app.is-animation-off .stage-hud,
.app.is-animation-off .play-bets {
    translate: 0 calc(-1 * var(--static-hud-lift, 0px));
}

/* ---- Last 3 seconds of the betting countdown: warning glow round the stage ----
   Added by game.js at 3 s left, removed at take-off. Sits over the canvas (z 0) and
   under the HUD / header; never takes clicks. Pulses once a second with the countdown. */
.cashout-glow {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.cashout-glow--warning {
    /* left + right edges only: soft eased falloff from each side, clear middle */
    background:
        linear-gradient(to right,
            rgba(255, 64, 48, 0.42) 0%,
            rgba(255, 64, 48, 0.26) 4%,
            rgba(255, 64, 48, 0.13) 9%,
            rgba(255, 64, 48, 0.05) 15%,
            rgba(255, 64, 48, 0) 22%,
            rgba(255, 64, 48, 0) 78%,
            rgba(255, 64, 48, 0.05) 85%,
            rgba(255, 64, 48, 0.13) 91%,
            rgba(255, 64, 48, 0.26) 96%,
            rgba(255, 64, 48, 0.42) 100%);
    /* taper the side glows out towards the header and the bet panels */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 6rem, #000 calc(100% - 3rem), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 6rem, #000 calc(100% - 3rem), transparent 100%);
    animation: cashout-glow-in 0.25s ease-out both, cashout-glow-pulse 1s ease-in-out 0.25s infinite;
}

@media (max-width: 47.9375rem) {
    .cashout-glow--warning {
        background:
            linear-gradient(to right,
                rgba(255, 64, 48, 0.32) 0%,
                rgba(255, 64, 48, 0.18) 5%,
                rgba(255, 64, 48, 0.08) 11%,
                rgba(255, 64, 48, 0.02) 18%,
                rgba(255, 64, 48, 0) 23%,
                rgba(255, 64, 48, 0) 77%,
                rgba(255, 64, 48, 0.02) 82%,
                rgba(255, 64, 48, 0.08) 89%,
                rgba(255, 64, 48, 0.18) 95%,
                rgba(255, 64, 48, 0.32) 100%);
        -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 4rem, #000 calc(100% - 2rem), transparent 100%);
        mask-image: linear-gradient(to bottom, transparent 0, #000 4rem, #000 calc(100% - 2rem), transparent 100%);
    }
}

@keyframes cashout-glow-in {
    from {
        opacity: 0;
    }
}

@keyframes cashout-glow-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.45;
    }
}

/* Animations off in the menu: steady glow, no pulsing */
.app.is-animation-off .cashout-glow--warning {
    animation: cashout-glow-in 0.25s ease-out both;
}

@media (prefers-reduced-motion: reduce) {
    .cashout-glow--warning {
        animation: none;
    }
}

/* Animations off: white "Flew Away!", red multiplier */
.app.is-animation-off .stage-hud.is-crashed .stage-hud__flew {
    color: #FFFFFF;
}

.stage-hud__multiplier {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

/* ---- Player rows ---------------------------------------------------------- */
.bets-row.bets-row--win {
    background-color: var(--Green-Green-op-10);
    box-shadow: inset 0 0 0 1px var(--Green-Green-op-15);
}

.bets-row.bets-row--win .bets-win,
.bets-row.bets-row--win .bets-x {
    color: var(--Green-Green-light);
}

.bets-row.bets-row--lost {
    opacity: 0.55;
}

.bets-row.bets-row--me {
    box-shadow: inset 0 0 0 1px var(--Primary-Primary-op-15);
}

/* ---- Round winners medals ------------------------------------------------- */
/* icon0 = 1st (centre), icon1 = 2nd (left), icon2 = 3rd (right) */
.rw-winner__icon0,
.rw-winner__icon1,
.rw-winner__icon2 {
    width: 1.5rem;
    height: 1.5rem;
    flex: 0 0 1.5rem;
    background: url("img/medal-1.webp") center / contain no-repeat;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.rw-winner__icon1 {
    background-image: url("img/medal-2.webp");
}

.rw-winner__icon2 {
    background-image: url("img/medal-3.webp");
}

.rw-winner--center .rw-winner__icon0 {
    width: 1.75rem;
    height: 1.75rem;
    flex-basis: 1.75rem;
}

.round-winners:not(.is-visible) {
    pointer-events: none;
}

/* ---- Win toast ------------------------------------------------------------ */
.win-toast-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.sc-toast {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    border-radius: var(--radius-max);
    background: linear-gradient(180deg, rgba(0, 205, 78, 0.92), rgba(0, 161, 59, 0.92));
    box-shadow: var(--shadow-l);
    color: #fff;
    font-family: Inter, sans-serif;
    white-space: nowrap;
    animation: sc-toast-in 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.sc-toast > .win-video {
    z-index: 0;
    opacity: 0.9;
}

.sc-toast__label,
.sc-toast__win {
    position: relative;
    z-index: 1;
}

.sc-toast.is-leaving {
    animation: sc-toast-out 0.25s ease both;
}

.sc-toast__label {
    display: flex;
    flex-direction: column;
    font-size: var(--font-size-text-xs);
    line-height: var(--line-height-text-xs);
    color: rgba(255, 255, 255, 0.8);
}

.sc-toast__label strong {
    font-size: var(--font-size-text-lg);
    line-height: var(--line-height-text-lg);
    color: #fff;
}

.sc-toast__win {
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-max);
    background: rgba(0, 0, 0, 0.2);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.sc-toast--error,
.sc-toast--info {
    background: linear-gradient(180deg, rgba(221, 59, 81, 0.95), rgba(226, 10, 40, 0.95));
    padding: 0.625rem 1rem;
    font-size: var(--font-size-text-sm);
    font-weight: 600;
}

/* notices (e.g. no free bets left) are not errors */
.sc-toast--info {
    background: linear-gradient(180deg, rgba(70, 72, 92, 0.96), rgba(48, 49, 64, 0.96));
}

@keyframes sc-toast-in {
    from {
        opacity: 0;
        transform: translateY(-0.75rem) scale(0.9);
    }
}

@keyframes sc-toast-out {
    to {
        opacity: 0;
        transform: translateY(-0.5rem) scale(0.95);
    }
}

/* ---- My bets rows --------------------------------------------------------- */
.sc-my-bet {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr 1fr 1fr;
    align-items: center;
    min-height: 2rem;
    padding: 0 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-max);
    background: var(--background-components-Disable);
    font-size: var(--font-size-text-sm);
    color: var(--Text-Icons-Secondary);
    font-variant-numeric: tabular-nums;
}

.sc-my-bet.is-win {
    background: var(--Green-Green-op-10);
}

.sc-my-bet.is-win .sc-my-bet__win {
    color: var(--Green-Green-light);
    font-weight: 700;
}

.sc-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--Text-Icons-Tertiary);
    font-size: var(--font-size-text-sm);
}

/* ---- Top tab rows --------------------------------------------------------- */
.sc-top-row .bets-cell:last-child {
    color: var(--Green-Green-light);
}

/* ---- Panel modes ---------------------------------------------------------
   style.css ships no layout for 1-panel; it is added here. 4-panel uses the
   .mode-4 layout from style.css.                                            */
.app.mode-1 [data-bet-panel="1"],
.app.mode-1 .bet-panel>.bet-sep {
    display: none !important;
}

/* 1 panel on phones: one classic row (stake controls | big Bet button);
   style.css sizes the classic dock for two rows, so shrink it to one. */
@media (max-width: 47.9375rem) {
    .app.mode-1.mode-classic .bet-dock {
        height: calc(8rem - var(--bet-dock-collapse, 0rem));
    }

    .app.mode-1.mode-classic .bet-panel {
        height: 6.5rem;
    }
}

/* 4 panels on phones: style.css has no phone layout for it, so put the
   2-panel cards in a 2x2 grid instead of one row that overflows the screen. */
@media (max-width: 47.9375rem),
(orientation: landscape) and (max-width: 63.9375rem) and (max-height: 30rem) {
    .app.mode-4 .bet-panel {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem 0.5rem;
        height: auto;
    }

    .app.mode-4 .bet-dock {
        height: auto;
    }

    .app.mode-4 .bet-panel>.bet-sep,
    .app.mode-4 .bet-panel>.bet-shared-head,
    .app.mode-4 .bet-panel>.bet-shared-foot {
        display: none !important;
    }

    .app.mode-4 .bet-panel>.bet-card {
        min-width: 0;
        width: auto;
    }
}

/* Menu: always the full 2x2 grid — 1 Panel Simple, 2 Panel New, 2 Panel Classic,
   4 Panel Pro (style.css collapses it to 3 cards on desktop). */
.menu-pop .mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.menu-pop .mode-grid>.mode-card,
.menu-pop .mode-grid>.mode-card:nth-child(2) {
    display: inline-flex;
    grid-column: auto;
}

.menu-pop .mode-grid>.mode-card:last-child {
    grid-column: auto;
}

.menu-pop .mode-card[data-bet-mode="classic"] .mode-icon--classic {
    display: inline-flex !important;
}

.menu-pop .mode-card[data-bet-mode="classic"] .mode-subtitle--classic {
    display: block !important;
}

.menu-pop .mode-card[data-bet-mode="classic"] .mode-icon--desktop-new,
.menu-pop .mode-card[data-bet-mode="classic"] .mode-subtitle--desktop-new,
.menu-pop .mode-card .mode-new-badge {
    display: none !important;
}

/* ---- History popup: show the round stats the script fills ---------------- */
#popup-history .history-multipliers {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    height: auto;
}

#popup-history .round-card {
    display: flex;
}

#popup-history .history-summary {
    display: flex;
}

/* ---- HUD loader hides during flight ------------------------------------- */
.stage-hud__loader[hidden] {
    display: none !important;
}

/* ---- Header history strip: arrow expands it in place to 3 rows ----------- */
.topbar.is-multipliers-open .multipliers {
    flex-wrap: wrap;
    align-content: flex-start;
    row-gap: var(--multipliers-gap, 0.25rem);
    max-height: var(--multipliers-expanded-h, calc(3 * 1.5rem + 2 * 0.25rem));
    /* overlay the stage instead of pushing it down: the grid row keeps its one-row height */
    margin-bottom: calc(var(--multipliers-expanded-h, calc(3 * 1.5rem + 2 * 0.25rem)) * -1 + 1.5rem);
    overflow: hidden;
    -webkit-mask-image: none;
    mask-image: none;
}

/* dark wash behind the open strip so the badges stay readable over the sky */
.topbar.is-multipliers-open::before {
    content: "";
    position: absolute;
    inset: 0 0 calc(var(--multipliers-expanded-h, calc(3 * 1.5rem + 2 * 0.25rem)) * -1 - 1rem) 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(10, 10, 18, 0.85) 0%, rgba(10, 10, 18, 0.7) 75%, rgba(10, 10, 18, 0) 100%);
}

/* the open strip covers where the round-winners bar sits */
.app.is-multipliers-open .round-winners {
    visibility: hidden !important;
}

.topbar>[data-multipliers-toggle] svg.icon {
    transition: transform 0.2s ease;
}

.topbar.is-multipliers-open>[data-multipliers-toggle] svg.icon {
    transform: rotate(180deg);
}

/* ---- Toasts sit below the history strip and the winners bar ------------- */
.win-toast-stack {
    top: 10.5rem;
}

/* Hide entry points this build does not implement */
.lobby-icon,
.version-switch,
.four-bet-switch {
    display: none !important;
}

/* ---- Free bets ("Freespins"): while one is selected the gift dock replaces the bet panels --- */
.app.is-gift-mode .bet-dock .gift-dock-header {
    display: flex;
}

.app.is-gift-mode .bet-dock .gift-dock-body {
    display: flex;
    gap: 2px;
    padding-bottom: 1rem;
}

.app.is-gift-mode .bet-dock .gift-summary,
.app.is-gift-mode .bet-dock .gift-bet-buttons {
    display: flex;
}

.app.is-gift-mode .bet-dock .bet-panel {
    display: none;
}

/* the desktop dock has a fixed height for the bet panels; header + summary + buttons need more */
.app.is-gift-mode .bet-dock {
    height: auto;
    padding: 0;
}
