@font-face {
    font-family: 'Coiny';
    src: url('/fonts/coiny.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

body {
    margin: 0;
    padding: 0;
    color: rgba(255, 255, 255, 0.87);
    background-color: #000000;
    overflow: hidden;
    /* Отключаем выделение текста */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Отключаем callout меню на iOS */
    -webkit-touch-callout: none;
    /* Фиксируем высоту для предотвращения скролла */
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
    overscroll-behavior: none;
}

/* Отключаем перетаскивание изображений */
img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    pointer-events: auto;
}

/* Отключаем перетаскивание canvas */
canvas {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
}

#pixi-container {
    /* Canvas будет масштабироваться через JS */
    position: relative;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
}

#pixi-container canvas {
    display: block;
    image-rendering: auto;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

/* Preloader Styles */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #2a2a2a;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
    /* Блокируем zoom, но разрешаем обычные взаимодействия */
    touch-action: manipulation;
    overscroll-behavior: none;
    overflow: hidden;
}

#preloader.hidden {
    opacity: 0;
    pointer-events: none;
}

.preloader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    transform-origin: center center;
}

.preloader-title-img {
    width: auto;
    height: 250px;
    margin: 50px 0 40px 0;
    object-fit: contain;
    image-rendering: auto;
}

.preloader-birds {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    height: 80px;
    margin-bottom: 40px;
}

.preloader-bird {
    width: 133px;
    height: 133px;
    object-fit: contain;
    image-rendering: pixelated;
}

.preloader-bar-container {
    width: 400px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 3px solid white;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.preloader-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #4a4a4a 0%, #6a6a6a 100%);
    border-radius: 20px;
    transform-origin: left center;
    transform: scaleX(0);
    animation: loading-bar 5s linear forwards;
    position: relative;
    will-change: transform;
}

.preloader-bar-circle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) translateX(0);
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: loading-circle 5s linear forwards;
    will-change: transform;
}

@keyframes loading-bar {
    0% {
        transform: scaleX(0);
    }
    100% {
        transform: scaleX(0.93);
    }
}

@keyframes loading-circle {
    0% {
        transform: translateY(-50%) translateX(0);
    }
    100% {
        transform: translateY(-50%) translateX(360px);
    }
}

.preloader-powered {
    margin-top: 10px;
}

.preloader-powered img {
    height: 10px;
    object-fit: contain;
}

.preloader-logo {
    margin-top: -5px;
}

.preloader-logo img {
    height: 27px;
    object-fit: contain;
}

/* Intro Screen Styles */
.intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Transparent — the REAL game canvas behind shows through, blurred
       via #pixi-container's filter while .intro-active is on body. */
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    transition: opacity 0.5s ease-out;
    overflow: hidden;
    touch-action: manipulation;
    overscroll-behavior: none;
}

/* While the intro is on screen the underlying game is blurred and
   slightly zoomed in — gives a "frosted glass" depth and matches the
   Knight Tales pattern of "pulling back to reveal the game". */
body.intro-active #pixi-container {
    filter: blur(12px);
    transform: scale(1.08);
    transition: filter 0.5s ease, transform 0.5s ease;
}
body:not(.intro-active) #pixi-container {
    transition: filter 0.5s ease, transform 0.5s ease;
}

.intro-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Corner BGaming logo (upper-left). Sized to match the in-game logo:
   35px square with 20px margin (see ResizeManager.resizeLogo). */
.intro-corner-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 35px;
    height: 35px;
    object-fit: cover;
    border-radius: 8px;
    z-index: 20;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Mute / Unmute button (upper-right). */
.intro-corner-mute {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: #f0f0f0;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 20;
    transition: transform 0.2s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.intro-corner-mute:hover {
    background-color: #e0e0e0;
    transform: scale(1.05);
}

.intro-corner-mute:active {
    background-color: #d0d0d0;
    transform: scale(1.0);
}

.intro-corner-mute img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.intro-corner-mute.muted img {
    opacity: 0.35;
}

.intro-corner-mute.muted::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    height: 3px;
    background-color: #d33;
    border-radius: 2px;
    transform: translateY(-50%) rotate(-30deg);
    pointer-events: none;
}

@media (max-width: 700px), (max-height: 500px) {
    .intro-corner-logo {
        top: 14px;
        left: 14px;
    }
    .intro-corner-mute {
        top: 14px;
        right: 14px;
        width: 38px;
        height: 38px;
    }
    .intro-corner-mute img {
        width: 20px;
        height: 20px;
    }
}

/* Static background layers are no longer used — the intro now shows
   the real (blurred) game canvas through transparency. Hidden via
   display:none rather than removed so the HTML stays compatible. */
.intro-global-bg { display: none !important; }

.intro-global-bg .intro-sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #18c5ff;
    z-index: 1;
}

.intro-global-bg .intro-clouds {
    position: absolute;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: auto;
    opacity: 0.6;
    z-index: 2;
}

.intro-global-bg .intro-fields {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 105%;
    height: auto;
    z-index: 3;
}

.intro-global-bg .intro-road {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 4;
    object-fit: cover;
}

/* ============================================
   INTRO SCREEN — Knight Tales–style 3-card layout
   ============================================
   Architecture (mirrors Knight Tales IntroScreen.css):
   • .intro-content is content-sized (NOT viewport-sized). JS measures
     its natural width/height and applies transform:scale() so the
     whole composition fits the viewport, never upscaling past 1×.
   • All internal dimensions use calc(... * var(--scale-factor, 1)).
   • Desktop / landscape: 3 cards in a row, centre slightly lower.
     Portrait mobile: cards stack vertically and a JS-driven carousel
     shows them one-at-a-time with dot navigation.
   • Frame artwork is applied later via background-image on .intro-card.
   ============================================ */

.intro-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    z-index: 5;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(20px * var(--scale-factor, 1));

    /* Content-sized so JS scale-to-fit works correctly */
    width: auto;
    max-width: none;
    padding: calc(10px * var(--scale-factor, 1)) calc(20px * var(--scale-factor, 1));
}

/* ============================================ LOGO */
.intro-logo-wrap {
    animation: introLogoIn 0.6s ease-out;
    flex-shrink: 0;
}
.intro-logo-image {
    max-width: calc(190px * var(--scale-factor, 1));
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 calc(4px * var(--scale-factor, 1)) calc(8px * var(--scale-factor, 1)) rgba(0, 0, 0, 0.5));
}
@keyframes introLogoIn {
    from { opacity: 0; transform: translateY(calc(-30px * var(--scale-factor, 1))); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================ CARDS ROW */
.intro-cards-row {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: calc(26px * var(--scale-factor, 1));
    margin: calc(8px * var(--scale-factor, 1)) 0;
}

/* Frame artwork — PNG with title banner on top, dark stone area in
   the middle, decorative green dot indicator at the bottom. Each card
   has its own frame with a different title. Aspect 449/600 ≈ 3:4. */
.intro-card {
    position: relative;
    width: calc(360px * var(--scale-factor, 1));
    aspect-ratio: 449 / 600;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    filter: drop-shadow(0 calc(8px * var(--scale-factor, 1)) calc(16px * var(--scale-factor, 1)) rgba(0, 0, 0, 0.55));
    will-change: transform, opacity;
}
.intro-card--left   { background-image: url('/games/lucky-birds/assets/ui/intro-frame-1.png'); }
.intro-card--center { background-image: url('/games/lucky-birds/assets/ui/intro-frame-2.png'); }
.intro-card--right  { background-image: url('/games/lucky-birds/assets/ui/intro-3-social.png'); }
.intro-card--center {
    margin-top: calc(40px * var(--scale-factor, 1));
}

/* Inner content sits inside the dark stone area of the frame.
   flex-end packs all children to the bottom of the inner box (just
   above the dot indicator) with a small gap — eliminates the wide
   empty middle that space-between was leaving between multiplier /
   bird / text. */
.intro-card-inner {
    position: absolute;
    inset: 26% 12% 14% 12%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: calc(0.1rem * var(--scale-factor, 1));
    text-align: center;
}

/* ============================================ LUCKY MAX SPLASH (card 1) */
.intro-lucky-max {
    width: 100%;
    max-width: calc(220px * var(--scale-factor, 1));
    height: auto;
    object-fit: contain;
    margin-bottom: calc(28px * var(--scale-factor, 1));
    filter: drop-shadow(0 calc(3px * var(--scale-factor, 1)) calc(6px * var(--scale-factor, 1)) rgba(0, 0, 0, 0.5));
}

/* ============================================ MULTIPLIER (card 1) */
.intro-multiplier-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    /* Pull the wrapper down toward the bird (negative bottom margin
       overlaps with the next sibling's top space). */
    margin-bottom: calc(-6px * var(--scale-factor, 1));
}
.intro-multiplier-prefix + .intro-multiplier,
.intro-multiplier-wrapper .intro-multiplier {
    margin-top: calc(-4px * var(--scale-factor, 1));
}
.intro-multiplier-prefix {
    font-family: 'Coiny', cursive;
    font-size: calc(20px * var(--scale-factor, 1));
    color: #ffffff;
    letter-spacing: 0.04em;
}
.intro-multiplier {
    font-family: 'Coiny', cursive;
    font-size: calc(52px * var(--scale-factor, 1));
    line-height: 1;
    color: #fbcb13;
    -webkit-text-stroke: calc(4px * var(--scale-factor, 1)) #000000;
    text-stroke: calc(4px * var(--scale-factor, 1)) #000000;
    paint-order: stroke fill;
    text-shadow: 0 calc(2px * var(--scale-factor, 1)) calc(4px * var(--scale-factor, 1)) rgba(0, 0, 0, 0.6);
}

/* ============================================ BIRDS / CARD INNER
   image-rendering: pixelated keeps the bird sprite-sheet crisp when
   scaled up from its 200×200 native frame. Without it canvases get
   bilinear-blurred ("мыльные"). */
.intro-bird-canvas {
    width: calc(130px * var(--scale-factor, 1));
    height: calc(130px * var(--scale-factor, 1));
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    filter: drop-shadow(0 calc(3px * var(--scale-factor, 1)) calc(6px * var(--scale-factor, 1)) rgba(0, 0, 0, 0.4));
}
.intro-card--center .intro-bird-canvas {
    width: calc(85px * var(--scale-factor, 1));
    height: calc(85px * var(--scale-factor, 1));
}
.intro-card--right .intro-bird-canvas {
    width: calc(72px * var(--scale-factor, 1));
    height: calc(72px * var(--scale-factor, 1));
}
.intro-card-birds {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(8px * var(--scale-factor, 1));
}
.intro-card-bird-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(2px * var(--scale-factor, 1));
}

/* ============================================ FINGER (card 2) */
.intro-finger-icon {
    width: calc(50px * var(--scale-factor, 1));
    height: auto;
    object-fit: contain;
    margin-top: calc(-8px * var(--scale-factor, 1));
    filter: drop-shadow(0 calc(2px * var(--scale-factor, 1)) calc(4px * var(--scale-factor, 1)) rgba(0, 0, 0, 0.5));
    animation: introFingerBob 1.4s ease-in-out infinite;
}
@keyframes introFingerBob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(calc(-6px * var(--scale-factor, 1))); }
}

/* ============================================ RISK LABELS (card 3) */
.intro-risk-label {
    font-family: 'Coiny', cursive;
    font-size: calc(16px * var(--scale-factor, 1));
    font-weight: bold;
    line-height: 1;
    -webkit-text-stroke: calc(2.5px * var(--scale-factor, 1)) #ffffff;
    paint-order: stroke fill;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.intro-risk-risky        { color: #ff4444; }
.intro-risk-mid          { color: #ffa500; }
.intro-risk-safe         { color: #0b24f5; }

.intro-risk-percent {
    font-family: 'Coiny', cursive;
    font-size: calc(22px * var(--scale-factor, 1));
    font-weight: bold;
    line-height: 1;
    -webkit-text-stroke: calc(3px * var(--scale-factor, 1)) #ffffff;
    paint-order: stroke fill;
}
.intro-risk-risky-percent { color: #ff4444; }
.intro-risk-mid-percent   { color: #ffa500; }
.intro-risk-safe-percent  { color: #0b24f5; }

/* ============================================ CARD TEXT */
.intro-card-text {
    font-family: 'Coiny', cursive;
    font-size: calc(18px * var(--scale-factor, 1));
    color: #ffffff;
    line-height: 1.25;
    text-align: center;
    padding: 0 calc(4px * var(--scale-factor, 1));
    text-shadow: 0 calc(2px * var(--scale-factor, 1)) calc(3px * var(--scale-factor, 1)) rgba(0, 0, 0, 0.6);
}
.intro-card-text .highlight {
    color: #fbcb13;
}

/* ============================================ START MESSAGE */
.intro-start-message {
    font-family: 'Coiny', cursive;
    font-size: calc(28px * var(--scale-factor, 1));
    color: #ffffff;
    text-align: center;
    letter-spacing: 0.1em;
    -webkit-text-stroke: calc(3px * var(--scale-factor, 1)) #000000;
    paint-order: stroke fill;
    text-shadow: 0 calc(3px * var(--scale-factor, 1)) calc(6px * var(--scale-factor, 1)) rgba(0, 0, 0, 0.6);
    animation: introPulse 1.8s ease-in-out infinite;
    margin-top: calc(8px * var(--scale-factor, 1));
}
@keyframes introPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

/* ============================================ CARD POP-IN ANIMATIONS */
.intro-card { opacity: 0; }
.intro-content:not(.intro-content--exiting) .intro-card {
    animation: introCardPop 0.7s ease-out both;
}
.intro-content:not(.intro-content--exiting) .intro-card--left   { animation-delay: 0.0s; }
.intro-content:not(.intro-content--exiting) .intro-card--center { animation-delay: 0.15s; }
.intro-content:not(.intro-content--exiting) .intro-card--right  { animation-delay: 0.30s; }
@keyframes introCardPop {
    0%   { opacity: 0; transform: scale(0.5); }
    55%  { opacity: 1; }
    70%  { transform: scale(1.06); }
    100% { opacity: 1; transform: scale(1); }
}

/* Continuous idle bob, kicks in after pop-in animation finishes. */
.intro-content:not(.intro-content--exiting) .intro-card--left {
    animation: introCardPop 0.7s ease-out both, introBob 3.2s ease-in-out 0.9s infinite;
}
.intro-content:not(.intro-content--exiting) .intro-card--center {
    animation: introCardPop 0.7s ease-out 0.15s both, introBob 3.2s ease-in-out 1.1s infinite;
}
.intro-content:not(.intro-content--exiting) .intro-card--right {
    animation: introCardPop 0.7s ease-out 0.30s both, introBob 3.2s ease-in-out 1.3s infinite;
}
@keyframes introBob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(calc(-8px * var(--scale-factor, 1))); }
}

/* ============================================ EXIT ANIMATIONS
   Staggered: left → right → centre, slingshot style. fill-mode `both`
   so the FROM keyframe (opacity:1) holds DURING animation-delay —
   without it the base `.intro-card { opacity:0 }` rule shows through
   for 120-240ms and the cards blink. */
.intro-content--exiting .intro-card--left {
    animation: introExitLeft 0.46s ease-in both !important;
}
.intro-content--exiting .intro-card--right {
    animation: introExitRight 0.46s ease-in 0.12s both !important;
}
.intro-content--exiting .intro-card--center {
    animation: introExitUp 0.46s ease-in 0.24s both !important;
}

/* Logo flies straight up off the screen on exit — no fade, just
   translate so it reads as moving away rather than dissolving. */
.intro-content--exiting .intro-logo-wrap {
    animation: introLogoFlyUp 0.55s ease-in forwards !important;
}

/* Dots vanish immediately on exit-tap — same treatment as
   PRESS TO START message. No fade with the rest of the content. */
.intro-content--exiting .intro-dots {
    display: none !important;
}
@keyframes introLogoFlyUp {
    0%   { transform: translateY(0);    opacity: 1; }
    100% { transform: translateY(-240%); opacity: 1; }
}
/* Explicit scale(1) in every frame so cards don't visually inflate
   when the previous popIn/bob animations release their transform. */
@keyframes introExitLeft {
    0%   { transform: scale(1) translateX(0);     opacity: 1; }
    28%  { transform: scale(1) translateX(14%);   opacity: 1; }
    100% { transform: scale(1) translateX(-185%); opacity: 0; }
}
@keyframes introExitRight {
    0%   { transform: scale(1) translateX(0);     opacity: 1; }
    28%  { transform: scale(1) translateX(-14%);  opacity: 1; }
    100% { transform: scale(1) translateX(185%);  opacity: 0; }
}
@keyframes introExitUp {
    0%   { transform: scale(1) translateY(0);     opacity: 1; }
    28%  { transform: scale(1) translateY(14%);   opacity: 1; }
    100% { transform: scale(1) translateY(-210%); opacity: 0; }
}

/* ============================================ DOTS (mobile carousel only) */
.intro-dots {
    display: none;
    justify-content: center;
    gap: calc(10px * var(--scale-factor, 1));
    margin-top: calc(8px * var(--scale-factor, 1));
}
.intro-dot {
    width: calc(12px * var(--scale-factor, 1));
    height: calc(12px * var(--scale-factor, 1));
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    border: calc(2px * var(--scale-factor, 1)) solid rgba(251, 203, 19, 0.6);
    cursor: pointer;
    transition: all 0.25s ease;
}
.intro-dot.active {
    background: #fbcb13;
    border-color: #fbcb13;
    transform: scale(1.25);
    box-shadow: 0 0 calc(8px * var(--scale-factor, 1)) rgba(251, 203, 19, 0.65);
}

/* ============================================ PORTRAIT MOBILE — carousel
   Cards stack vertically logically but only the active one is visible.
   Dots navigate between them. JS toggles .is-active on the current card. */
@media (orientation: portrait) {
    .intro-cards-row {
        position: relative;
        display: block;
        width: calc(320px * var(--scale-factor, 1));
        /* Card aspect is 449/600 → height = width * (600/449) ≈ 1.337 */
        height: calc(427px * var(--scale-factor, 1));
        margin: calc(4px * var(--scale-factor, 1)) 0;
    }
    .intro-card {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        margin: 0 !important;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .intro-card.is-active {
        opacity: 1;
        pointer-events: auto;
    }
    /* Disable desktop bob/pop animations on mobile — they conflict with
       the carousel's fade transitions. */
    .intro-content:not(.intro-content--exiting) .intro-card {
        animation: none !important;
    }
    .intro-card.is-active.intro-card--enter-pop {
        animation: introCardPop 0.5s ease-out both !important;
    }
    /* On exit in portrait, only the currently-visible (active) card
       flies out. The two off-screen cards stay hidden — no animation
       so their absent presence doesn't leak through. */
    .intro-content--exiting .intro-card:not(.is-active) {
        display: none !important;
    }
    /* Active card exits via a single upward flight regardless of which
       card slot it originally lived in (left/right/centre exit rules
       don't fit the carousel — one card = one motion). */
    .intro-content--exiting .intro-card.is-active {
        animation: introExitUp 0.46s ease-in both !important;
    }
    .intro-dots {
        display: flex;
    }
}

/* ============================================
   ERROR POPUP STYLES
   ============================================ */

.error-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    /* Блокируем zoom, но разрешаем обычные взаимодействия */
    touch-action: manipulation;
    overscroll-behavior: none;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.error-popup.hidden {
    opacity: 0;
    pointer-events: none;
}

.error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.error-modal {
    position: relative;
    background: linear-gradient(145deg, #303030, #252525);
    border-radius: 20px;
    padding: 30px 40px;
    min-width: 320px;
    max-width: 500px;
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.8),
        0 15px 40px rgba(0, 0, 0, 0.6),
        0 5px 15px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    animation: errorPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

@keyframes errorPopIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.error-icon {
    width: 60px;
    height: 60px;
    display: block;
    margin: 0 auto 15px auto;
    animation: errorShake 0.5s ease;
}

@keyframes errorShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.error-title {
    font-family: 'Coiny', cursive;
    font-size: 40px;
    color: #ffffff;
    margin: 0 0 15px 0;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.error-message {
    font-family: 'Coiny', cursive;
    font-size: 20px;
    color: #ffffff;
    margin-bottom: 25px;
    line-height: 1.5;
    text-align: center;
}

.error-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.error-btn {
    font-family: 'Coiny', cursive;
    font-size: 18px;
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    min-width: 120px;
}

.error-btn-primary {
    background-color: #fbcb13;
    color: #000000;
    box-shadow: 0 4px 0 #ff7200;
}

.error-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #ff7200;
}

.error-btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #ff7200;
}

.error-btn-secondary {
    background-color: #4CAF50;
    color: #ffffff;
    box-shadow: 0 4px 0 #2e7d32;
}

.error-btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #2e7d32;
}

.error-btn-secondary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #2e7d32;
}

.error-btn.hidden {
    display: none;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    .error-modal {
        min-width: 260px;
        max-width: 85%;
        padding: 20px 15px;
    }

    .error-icon {
        width: 40px;
        height: 40px;
        margin: 0 auto 10px auto;
    }

    .error-title {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .error-message {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .error-btn {
        font-size: 14px;
        padding: 10px 15px;
        min-width: 90px;
        max-width: 150px;
    }

    .error-buttons {
        gap: 10px;
        justify-content: center;
    }
}

/* ============================================
   RESTORATION POPUP (Game State Restored)
   ============================================ */

.restoration-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* BGPP-1151: BELOW preloader (9999) — the restoration popup must
       stay hidden by the preloader until the preloader fades out.
       Previously 10001 which showed the popup ABOVE preloader. */
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    /* Блокируем zoom, но разрешаем обычные взаимодействия */
    touch-action: manipulation;
    overscroll-behavior: none;
    overflow: hidden;
}

.restoration-popup.hidden {
    opacity: 0;
    pointer-events: none;
}

.restoration-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.restoration-modal {
    position: relative;
    background: linear-gradient(145deg, #1a4d2e, #2d5f3f);
    border-radius: 20px;
    padding: 30px 40px;
    min-width: 320px;
    max-width: 500px;
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.8),
        0 15px 40px rgba(0, 0, 0, 0.6),
        0 5px 15px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: slideIn 0.3s ease;
}

.restoration-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.restoration-title {
    font-family: 'Coiny', cursive;
    font-size: 36px;
    color: #4ade80;
    margin: 0 0 15px 0;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.restoration-message {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    color: #e0e0e0;
    text-align: center;
    line-height: 1.5;
    margin: 0 0 25px 0;
    max-width: 400px;
}

.restoration-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
}

.restoration-btn {
    font-family: 'Coiny', cursive;
    font-size: 18px;
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    min-width: 120px;
}

.restoration-btn-primary {
    background-color: #4ade80;
    color: #000000;
    box-shadow: 0 4px 0 #22c55e;
}

.restoration-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #22c55e;
}

.restoration-btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #22c55e;
}

.restoration-btn.hidden {
    display: none;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    .restoration-modal {
        min-width: 280px;
        max-width: 90%;
        padding: 25px 20px;
    }

    .restoration-title {
        font-size: 24px;
    }

    .restoration-message {
        font-size: 14px;
    }

    .restoration-btn {
        font-size: 16px;
        padding: 10px 20px;
        min-width: 100px;
        width: 100%;
    }
}

/* ============================================
   MAX WIN POPUP (BGPP-1240)
   ============================================ */

.maxwin-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10002; /* Above error popup */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    touch-action: manipulation;
    overscroll-behavior: none;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

.maxwin-popup.hidden {
    opacity: 0;
    pointer-events: none;
}

.maxwin-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.maxwin-modal {
    position: relative;
    background: linear-gradient(145deg, #5a3700, #b87a00);
    border-radius: 22px;
    padding: 32px 40px;
    min-width: 320px;
    max-width: 520px;
    /* Guarantee the popup always fits inside the visible viewport. We use
       100dvh (dynamic viewport height) so that mobile browser chrome
       (URL bar etc.) is excluded — 100vh on iOS/Android Safari reports
       the layout viewport including hidden chrome and the popup ended up
       taller than the visible area. JS-side scale-to-fit (showMaxWinPopup
       in src/index.js) is the belt-and-braces backstop on top of this. */
    max-height: calc(100dvh - 32px);
    /* BGPP-668: in short landscape viewports the content could exceed
       max-height and get clipped. Allow internal scroll so the action
       button is always reachable. */
    overflow-y: auto;
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.8),
        0 15px 40px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border: 2px solid #fbcb13;
    text-align: center;
    animation: errorPopIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Landscape / short viewports: compact paddings + font-sizes so the
   modal contents fit without scrolling and the action button is always
   visible above the fold. */
@media (max-height: 600px) {
    .maxwin-modal {
        padding: 14px 24px;
        border-radius: 16px;
    }
    .maxwin-icon {
        width: 56px;
        height: 56px;
        margin-bottom: 6px;
    }
    .maxwin-title {
        font-size: 24px;
        margin: 0 0 6px 0;
    }
    .maxwin-message {
        font-size: 16px;
        margin-bottom: 14px;
        line-height: 1.3;
    }
    .maxwin-btn {
        font-size: 16px;
        padding: 8px 22px;
        min-width: 110px;
    }
}

/* BGPP-668: ultra-short landscape (e.g. phones in landscape with
   visible browser chrome) — go further with the compact treatment so
   icon + title + message + button all fit inside the visible viewport
   without scrolling. */
@media (orientation: landscape) and (max-height: 460px) {
    .maxwin-modal {
        padding: 10px 18px;
        max-height: calc(100dvh - 16px);
    }
    .maxwin-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 4px;
    }
    .maxwin-title {
        font-size: 20px;
        margin: 0 0 4px 0;
    }
    .maxwin-message {
        font-size: 13px;
        margin-bottom: 8px;
        line-height: 1.2;
    }
    .maxwin-btn {
        font-size: 14px;
        padding: 6px 18px;
        min-width: 90px;
    }
}

/* BGPP-1241 (review): auto-loss variant (user did NOT cash out, hit the
   cap as a loss). Red palette so the popup doesn't read as a celebratory
   win — gold is reserved for the actual MAX WIN cashout case. */
.maxwin-modal.maxwin-modal--autoloss {
    background: linear-gradient(145deg, #5a0e0e, #b22828);
    border-color: #ff5252;
}

.maxwin-modal.maxwin-modal--autoloss .maxwin-title {
    color: #ffffff;
}

.maxwin-icon {
    width: 90px;
    height: 90px;
    display: block;
    margin: 0 auto 12px auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.maxwin-title {
    font-family: 'Coiny', cursive;
    font-size: 36px;
    color: #fbcb13;
    margin: 0 0 12px 0;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.5px;
}

.maxwin-message {
    font-family: 'Coiny', cursive;
    font-size: 20px;
    color: #ffffff;
    margin-bottom: 26px;
    line-height: 1.45;
}

.maxwin-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.maxwin-btn {
    font-family: 'Coiny', cursive;
    font-size: 18px;
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    min-width: 140px;
}

.maxwin-btn-primary {
    background-color: #fbcb13;
    color: #000000;
    box-shadow: 0 4px 0 #ff7200;
}

.maxwin-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #ff7200;
}

.maxwin-btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #ff7200;
}

@media (max-width: 600px) {
    .maxwin-modal {
        min-width: 260px;
        max-width: 88%;
        padding: 22px 18px;
    }
    .maxwin-icon {
        width: 60px;
        height: 60px;
    }
    .maxwin-title {
        font-size: 22px;
    }
    .maxwin-message {
        font-size: 15px;
        margin-bottom: 18px;
    }
    .maxwin-btn {
        font-size: 14px;
        padding: 10px 18px;
        min-width: 110px;
    }
}

/* ============================================
   GAME LOADER (BGPP-213: shown while waiting for play response between pipes)
   ============================================ */

.game-loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9990; /* Above canvas, below popups */
    pointer-events: none;
    transition: opacity 0.2s ease;
    opacity: 1;
}

.game-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.game-loader-spinner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 6px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fbcb13;
    animation: gameLoaderSpin 0.9s linear infinite;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    background: rgba(0, 0, 0, 0.35);
}

@keyframes gameLoaderSpin {
    to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    .game-loader-spinner {
        width: 44px;
        height: 44px;
        border-width: 5px;
    }
}

/* ============================================
   BET DROPDOWN — menu-modal style, positioned dynamically above bet oval
   ============================================ */

.bet-dropdown {
    position: fixed;
    z-index: 10005;
    background: linear-gradient(145deg, #303030, #252525);
    border-radius: 16px;
    padding: 12px 10px;
    min-width: 180px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 8px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: betDropdownIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: center bottom;
    display: flex;
    flex-direction: column;
    gap: 4px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.bet-dropdown.hidden {
    display: none;
}
@keyframes betDropdownIn {
    from { opacity: 0; transform: translateY(6px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bet-dropdown-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 50vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    -webkit-overflow-scrolling: touch;
}
.bet-dropdown-list::-webkit-scrollbar {
    width: 6px;
}
.bet-dropdown-list::-webkit-scrollbar-track {
    background: transparent;
}
.bet-dropdown-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
}
.bet-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.bet-dropdown-item {
    padding: 10px 16px;
    border-radius: 10px;
    background: transparent;
    color: #ffffff;
    font-family: 'Coiny', cursive;
    font-size: 18px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease;
    touch-action: manipulation;
}

.bet-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.bet-dropdown-item.active {
    background: #fbcb13;
    color: #000000;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3) inset;
}

/* Backdrop scrim — full-screen invisible click-blocker while dropdown is open */
.bet-dropdown-scrim {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10004;
    background: transparent;
}
.bet-dropdown-scrim.hidden {
    display: none;
}
