.card-game-window {
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow: hidden;
    width: 100%;
    height: 100%;
    background: url("assets/my-background.png") center center / cover no-repeat;
}

.card-game-window[hidden] {
    display: none;
}

.card-game-picture {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.card-game-background {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(1.05);
    transform-origin: center;
}

/* Настройки телефона */
@media (max-width: 700px) {
    .card-game-window {
        width: 100vw;
        height: 100dvh;
        inset: 0;
    }

    .card-game-background {
        width: 100%;
        height: 100%;
        object-fit: fill;
        transform: scale(1.1, 0.9);
        transform-origin: center center;
    }
}

/* Размер картинки на ПК */
@media (min-width: 701px) {
    .card-game-background {
        transform: scale(1.3, 1.25);
        transform-origin: center center;
    }
}

/* Убираем синее выделение при нажатии */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}
/* Общая позиция стопки карт */
.card-stack {
    position: absolute;

    left: 13%;
    top: 50%;

    width: 0;
    height: 0;

    transform: translate(0, -50%);
    z-index: 10;
}

/* Размер обеих карт */
.card-back,
.random-game-card {
    position: absolute;
    width: 90px;
    height: 130px;
    object-fit: fill;
}

.random-game-card {
    left: 18px;
    top: 0.7px;
    transform: translate(-50%, -50%) rotate(90deg);
    z-index: 1;
}

/* Рубашка — сверху и по центру */
.card-back {
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    z-index: 2;
}

/* Обводка */
.mobile-game-outline {
    display: none;
}

@media (max-width: 700px) {
    .mobile-game-outline {
        display: block;
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: fill;

        transform: scale(1.01, 0.75);
        transform-origin: center center;

        z-index: 100;
        pointer-events: none;
    }
}

/* Телефон */
@media (max-width: 700px) {
    .card-back,
    .random-game-card {
        width: 70px;
        height: 105px;
    }

    .mobile-game-outline {
        display: block;
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: fill;
        z-index: 100;
        pointer-events: none;
    }
}
/* Положение карт на ПК */
@media (min-width: 701px) {

    .card-stack {
        left: 30%; /* двигает обе карты влево или вправо */
    }

    .card-back,
    .random-game-card {
        width: 140px;
        height: 200px;
    }

    .random-game-card {
        left: 45px;
        top: 0.7px;
    }
}

/* Карты, которые вылетают из колоды */
.dealt-card {
    position: absolute;
    object-fit: fill;
    border-radius: 9px;
    overflow: hidden;
    pointer-events: auto;
    touch-action: none;

    transition:
        left 0.4s ease,
        top 0.4s ease,
        transform 0.2s ease,
        filter 0.2s ease;

    transform-origin: center center;
    will-change: left, top, transform;
    z-index: 30;
}

@media (max-width: 700px) {
    .dealt-card {
        border-radius: 6px;
    }
}

@media (max-width: 700px) {
    .dealt-card {
        border-radius: 6px;
    }
}

.dealt-card {
    pointer-events: auto;
    cursor: pointer;
    transition:
        left 0.4s ease,
        top 0.4s ease,
        transform 0.2s ease,
        filter 0.2s ease;
}

.dealt-card.card-hover {
    z-index: 1000 !important;
    transform:
        translateY(-22px)
        rotate(var(--card-angle))
        scale(1.05) !important;
}

.dealt-card.card-selected {
    z-index: 1100 !important;
    transform:
        translateY(-30px)
        rotate(var(--card-angle))
        scale(1.08) !important;
    filter: brightness(1.1);
}
#skipTurnButton,
#drawCardButton {
    position: absolute;
    z-index: 9000;
    width: 145px;
    height: 65px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
}

#skipTurnButton img,
#drawCardButton img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Компьютер */
@media (min-width: 701px) {
    #skipTurnButton {
        left: 25%;
        bottom: 4%;
    }

    #drawCardButton {
        right: 25%;
        bottom: 4%;
    }
}

/* Телефон */
@media (max-width: 700px) {
    #skipTurnButton,
    #drawCardButton {
        width: 90px;
        height: 48px;
        bottom: 14%;
    }

    #skipTurnButton {
        left: 3%;
    }

    #drawCardButton {
        right: 3%;
    }
}
/* Плавная анимация кнопок */
#skipTurnButton,
#drawCardButton {
    transition: transform 0.12s ease, filter 0.12s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#skipTurnButton:active,
#drawCardButton:active,
#skipTurnButton.pressed,
#drawCardButton.pressed {
    transform: scale(0.88);
    filter: brightness(0.8);
}
#skipTurnButton,
#drawCardButton {
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none;
}

#skipTurnButton:focus,
#drawCardButton:focus,
#skipTurnButton:focus-visible,
#drawCardButton:focus-visible {
    outline: none;
    box-shadow: none;
}
.game-result-image {
    position: absolute;
    left: 50%;
    top: 60%;

    width: min(55%, 420px);
    max-height: 55%;

    object-fit: contain;
    object-position: center;

    z-index: 10000;
    pointer-events: none;

    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);

    animation: resultBounce 1.8s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes resultBounce {
    /* Появляется снизу */
    0% {
        opacity: 0;
        transform: translate(-50%, 180%) scale(0.85, 0.85);
    }

    /* Взлетает */
    30% {
        opacity: 0.72;
        transform: translate(-50%, -150%) scale(1, 1);
    }

    /* Быстро падает и сжимается при ударе */
    52% {
        transform: translate(-50%, -50%) scale(1.12, 0.88);
    }

    /* Отталкивается от земли */
    65% {
        transform: translate(-50%, -105%) scale(0.94, 1.08);
    }

    /* Второе приземление */
    76% {
        transform: translate(-50%, -50%) scale(1.07, 0.93);
    }

    /* Маленький отскок */
    84% {
        transform: translate(-50%, -72%) scale(0.98, 1.03);
    }

    /* Окончательное приземление */
    92% {
        transform: translate(-50%, -50%) scale(1.03, 0.97);
    }

    100% {
        opacity: 0.85;
        transform: translate(-50%, -50%) scale(1, 1);
    }
}

@media (max-width: 700px) {
    .game-result-image {
        width: 65%;
        max-height: 45%;
    }
}

/* Кнопка выхода из игры */
.exit-game-button {
    position: absolute;
    top: 18px;
    right: 18px;

    width: 55px;
    height: 55px;

    padding: 0;
    border: none;
    background: transparent;

    cursor: pointer;
    z-index: 20000;
}

.exit-game-button img {
    width: 100%;
    height: 100%;
    object-fit: contain;

    display: block;
}

.exit-game-button:hover {
    transform: scale(1.1);
}

.exit-game-button:active {
    transform: scale(0.9);
}

@media (max-width: 700px) {
    .exit-game-button {
        width: 42px;
        height: 42px;
        top: 10px;
        right: 10px;
    }
}

/* ===== ПАНЕЛЬ РЕЗУЛЬТАТА ===== */
.result-panel {
    position: absolute;
    z-index: 10000;

    left: 50%;
    top: 50%;

    width: min(620px, 85%);
    height: 100px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;

    transform: translate(-50%, -50%);
    opacity: 0.88;

    cursor: grab;
    touch-action: pan-y;
    user-select: none;
}

.result-panel[hidden] {
    display: none;
}

.result-panel-background {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;

    opacity: 0.88;
}

.result-panel button {
    position: relative;
    z-index: 1;

    width: 45%;
    max-width: 145px;
    padding: 0;

    border: none;
    background: transparent;
    cursor: pointer;
}

.result-panel button img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.result-panel.dragging {
    cursor: grabbing;
}

/* ===== ЖЕЛЕЙНОЕ ПОКАЧИВАНИЕ ===== */
@keyframes jelly-shake {
    0%   { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
    20%  { transform: translate(-50%, -50%) rotate(-2deg) scale(1.04, 0.96); }
    40%  { transform: translate(-50%, -50%) rotate(2deg) scale(0.97, 1.04); }
    60%  { transform: translate(-50%, -50%) rotate(-1.5deg) scale(1.03, 0.97); }
    80%  { transform: translate(-50%, -50%) rotate(1deg) scale(0.99, 1.02); }
    100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}

.result-panel.jelly {
    animation: jelly-shake 0.55s ease;
}

/* ===== ТЕЛЕФОН ===== */
@media (max-width: 600px) {
    .result-panel {
        width: 92%;
        height: 78px;
        top: 50%;
        gap: 18px;
    }

    .result-panel button {
        width: 55%;
        max-width: 115px;
    }
}

/* Панель не перетаскивается */
.result-panel {
    cursor: pointer;
    touch-action: manipulation;
}


@keyframes jelly-zigzag {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) scaleX(1);
    }

    12% {
        transform: translate(calc(-50% - 18px), -50%) rotate(-5deg) scaleX(1.08);
    }

    25% {
        transform: translate(calc(-50% + 18px), -50%) rotate(5deg) scaleX(0.92);
    }

    38% {
        transform: translate(calc(-50% - 13px), -50%) rotate(-4deg) scaleX(1.06);
    }

    51% {
        transform: translate(calc(-50% + 13px), -50%) rotate(4deg) scaleX(0.95);
    }

    64% {
        transform: translate(calc(-50% - 8px), -50%) rotate(-2.5deg) scaleX(1.03);
    }

    77% {
        transform: translate(calc(-50% + 8px), -50%) rotate(2deg) scaleX(0.98);
    }

    90% {
        transform: translate(calc(-50% - 3px), -50%) rotate(-1deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(0deg) scaleX(1);
    }
}

.result-panel.jelly {
    animation: jelly-zigzag 0.9s cubic-bezier(.36, .07, .19, .97);
}

/* Индикатор выбранной масти */
.selected-suit-indicator {
    position: absolute;
    right: 3%;
    top: 50%;

    width: 65px;
    height: 65px;

    object-fit: contain;
    transform: translateY(-50%);

    z-index: 5000;
    pointer-events: none;
}

/* Размер для телефона */
@media (max-width: 600px) {
    .selected-suit-indicator {
        width: 42px;
        height: 42px;
        right: 2%;
    }
}
.dealt-card.card-dragging {
    transition: none;
    will-change: transform;
}
