/* Скрытие элементов */
.hidden {
    display: none !important;
}

/* Оригинальная маленькая круглая кнопка */
.game-start-btn-original {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 1000002;
    transition: transform 0.2s, box-shadow 0.2s;
    pointer-events: all;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-start-btn-original img {
    width: 45px;
    height: 45px;
    filter: brightness(0) invert(1);
}

.game-start-btn-original:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.game-start-btn-original:active {
    transform: scale(1);
}

.game-start-btn-original.pulse {
    animation: pulse-original 2s infinite;
}

@keyframes pulse-original {
    0% {
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 4px 25px rgba(102, 126, 234, 0.7);
    }
    100% {
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }
}

/* Старая версия - секция с большой кнопкой */
.game-intro-section {
    text-align: center;
    padding: 40px 20px;
    max-width: 900px;
    margin: 0 auto;
}

.game-intro-title {
    font-size: 32px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-intro-description {
    font-size: 18px;
    color: #555;
    margin-bottom: 30px;
    line-height: 1.5;
}

/* Превью картинок для старой версии */
.game-preview {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.preview-card {
    width: 150px;
    height: 220px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s, box-shadow 0.3s;
    animation: float 3s ease-in-out infinite;
}

.preview-card:nth-child(1) {
    animation-delay: 0s;
}

.preview-card:nth-child(2) {
    animation-delay: 0.5s;
}

.preview-card:nth-child(3) {
    animation-delay: 1s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.preview-card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.3);
}

.preview-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Большая кнопка для старой версии */
.game-start-btn-large {
    padding: 20px 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    transition: transform 0.3s, box-shadow 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 20px;
    font-weight: bold;
}

.game-start-icon {
    width: 35px;
    height: 35px;
    filter: brightness(0) invert(1);
}

.game-start-text {
    letter-spacing: 1px;
}

.game-start-btn-large.pulse {
    animation: pulse-large 2s infinite;
}

@keyframes pulse-large {
    0% {
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 8px 40px rgba(102, 126, 234, 0.8);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
        transform: scale(1);
    }
}

.game-start-btn-large:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.7);
}

.game-start-btn-large:active {
    transform: translateY(0) scale(1.02);
}

/* Компактный виджет игры */
.game-intro-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000002;
    max-width: 450px;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

a.game-intro-widget,
a.game-intro-widget:hover,
a.game-intro-widget:visited {
    text-decoration: none;
    color: inherit;
}

.game-intro-widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.25);
}

.game-intro-widget:active {
    transform: translateY(0);
}

.widget-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.widget-icon img {
    width: 50px;
    height: 50px;
}

.widget-content {
    flex: 1;
    min-width: 0;
}

.widget-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.4;
}

.widget-subtitle {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

/* Кнопка в виджете */
.game-start-btn-widget {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    margin-left: 6px;
}

.game-start-btn-widget:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.game-start-btn-widget:active {
    transform: scale(0.98);
}

/* Пульсирующая анимация для виджета */
.game-start-btn-widget.pulse {
    animation: pulse-widget 2.5s infinite;
}

@keyframes pulse-widget {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(102, 126, 234, 0);
    }
}

/* Оверлей игры */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    box-sizing: border-box;
    touch-action: none;
}

.game-overlay.game-hidden {
    display: none !important;
    pointer-events: none !important;
}

/* Сетка игры */
.game-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    width: 90vw;
    max-width: 900px;
    height: calc(100vh - 200px);
    height: calc(100dvh - 200px);
    max-height: 900px;
}

/* Карточка */
.game-grid .card {
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    pointer-events: all;
    perspective: 1000px;
    border-radius: 15px;
}

.game-grid .card.flipped {
    transform: rotateY(180deg);
}

.game-grid .card.matched {
    pointer-events: none;
}

.game-grid .card.matched img {
    opacity: 0.7;
}

/* Стороны карточки */
.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-style: preserve-3d;
}

.card-front {
    z-index: 2;
    border-radius: 15px;
    overflow: hidden;
}

.card-back {
    background: white;
    transform: rotateY(180deg);
    border-radius: 15px;
    overflow: hidden;
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Панель информации */
.game-info {
    display: flex;
    gap: 20px;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
    padding: 15px 30px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.info-item {
    color: white;
    font-size: 16px;
}

.info-item strong {
    color: #667eea;
    font-size: 20px;
}

.restart-btn,
.close-btn,
.share-game-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.restart-btn {
    background: #667eea;
    color: white;
}

.restart-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.close-btn {
    background: #e74c3c;
    color: white;
}

.close-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.share-game-btn {
    background: #27ae60;
    color: white;
}

.share-game-btn:hover {
    background: #229954;
    transform: translateY(-1px);
}

/* Модальное окно победы */
.game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000003;
}

.game-modal.game-hidden {
    display: none !important;
    pointer-events: none !important;
}

.game-modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.game-modal-content h2 {
    font-size: 32px;
    margin-bottom: 15px;
    color: #667eea;
}

.game-modal-content p {
    font-size: 18px;
    margin-bottom: 10px;
    color: #333;
}

.gamebtn-primary,
.gamebtn-secondary,
.gamebtn-share {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px 5px;
    transition: transform 0.2s;
}

.gamebtn-primary {
    background: #667eea;
    color: white;
}

.gamebtn-primary:hover {
    transform: translateY(-2px);
    background: #5568d3;
}

.gamebtn-secondary {
    background: #95a5a6;
    color: white;
}

.gamebtn-secondary:hover {
    transform: translateY(-2px);
    background: #7f8c8d;
}

.gamebtn-share {
    background: #27ae60;
    color: white;
}

.gamebtn-share:hover {
    transform: translateY(-2px);
    background: #229954;
}

/* Секция шаринга в модальном окне победы */
.victory-share-section {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
}

.victory-share-section h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #333;
}

.victory-share-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.victory-share-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.victory-share-btn:hover {
    transform: translateY(-2px);
}

.victory-share-btn.vk {
    background: #0077ff;
}

.victory-share-btn.whatsapp {
    background: #25d366;
}

.victory-share-btn.telegram {
    background: #0088cc;
}

.victory-copy {
    display: flex;
    gap: 10px;
    align-items: center;
}

.victory-url-input {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

.victory-copy-btn {
    flex-shrink: 0;
    padding: 10px 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    white-space: nowrap;
}

.victory-copy-btn:hover {
    background: #5568d3;
}

/* Модальное окно шаринга */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.share-modal-content {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    position: relative;
}

.share-modal-content h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #333;
}

.share-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.share-close-btn:hover {
    color: #333;
}

.share-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.share-btn-social {
    flex: 1;
    padding: 12px;
    text-align: center;
    text-decoration: none;
    color: white;
    border-radius: 8px;
    font-weight: bold;
    transition: transform 0.2s;
}

.share-btn-social:hover {
    transform: translateY(-2px);
}

.share-btn-social.vk {
    background: #0077ff;
}

.share-btn-social.whatsapp {
    background: #25d366;
}

.share-btn-social.telegram {
    background: #0088cc;
}

.share-copy {
    display: flex;
    gap: 10px;
    align-items: center;
}

.share-url-input {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.share-copy-btn {
    flex-shrink: 0;
    padding: 10px 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    white-space: nowrap;
}

.share-copy-btn:hover {
    background: #5568d3;
}

/* Адаптивность */
@media (max-width: 768px) {
    .game-overlay {
        padding: 10px;
    }

    .game-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, 1fr);
        width: 95vw;
        height: calc(100vh - 180px);
        height: calc(100dvh - 180px);
    }

    .game-info {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px;
    }

    .game-intro-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        padding: 12px;
    }

    .widget-icon {
        width: 40px;
        height: 40px;
    }

    .widget-icon img {
        width: 40px;
        height: 40px;
    }

    .widget-title {
        font-size: 14px;
    }

    .widget-subtitle {
        font-size: 12px;
    }

    .game-start-btn-widget {
        padding: 8px 16px;
        font-size: 13px;
    }

    /* Адаптивность для старой версии */
    .game-intro-title {
        font-size: 24px;
    }

    .game-intro-description {
        font-size: 16px;
    }

    .preview-card {
        width: 100px;
        height: 150px;
    }

    .game-start-btn-large {
        padding: 15px 35px;
        font-size: 18px;
    }

    .game-start-icon {
        width: 28px;
        height: 28px;
    }
}

/* ===========================
   Yandex widget
   =========================== */
#toTop {
  bottom: 150px;
}
.yabro-frame {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 470px;
    height: 110px;
    border: 0;
    background: transparent;
    z-index: 1000002;
    color-scheme: normal;
}

@media (max-width: 600px) {
    .yabro-frame {
        right: 10px;
        left: 10px;
        bottom: 10px;
        width: auto;
        height: 110px;
    }
}

.yabro-widget {
    padding-top: 22px;
    overflow: visible;
}

.yabro-editors-pick {
    position: absolute;
    top: -12px;
    left: 16px;
    background: linear-gradient(135deg, #ffd84d 0%, #ffb800 100%);
    color: #1a1a1a;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 6px 10px;
    border-radius: 8px;
    /* box-shadow: 0 3px 10px rgba(255, 184, 0, 0.35); */
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
}

.yabro-star {
    display: inline-block;
    line-height: 1;
    transform: translateY(-1px);
    font-size: 1.05em;
}

.yabro-widget .widget-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.yabro-badge-free {
    display: inline-block;
    background: #e8f7ec;
    color: #1f8a3a;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.4;
}

.yabro-icon-wiggle {
    animation: yabro-wiggle 3.2s ease-in-out infinite;
    transform-origin: 50% 80%;
}

@keyframes yabro-wiggle {
    0%, 70%, 100% { transform: rotate(0deg); }
    77%           { transform: rotate(-10deg); }
    84%           { transform: rotate(8deg); }
    91%           { transform: rotate(-5deg); }
}

@media (prefers-reduced-motion: reduce) {
    .yabro-icon-wiggle { animation: none; }
}

@media (max-width: 600px) {
    .yabro-widget {
        gap: 10px;
        padding: 22px 12px 12px;
    }
    .yabro-editors-pick {
        font-size: 9px;
        top: -12px;
        left: 12px;
        letter-spacing: 0.2px;
    }
    .yabro-widget .widget-title {
        font-size: 13px;
        gap: 6px;
        line-height: 1.4;
    }
    .yabro-badge-free {
        font-size: 9px;
        padding: 1px 5px;
        letter-spacing: 0.2px;
    }
    .yabro-widget .widget-subtitle {
        font-size: 11px;
    }
    .yabro-widget .widget-icon,
    .yabro-widget .widget-icon img {
        width: 36px;
        height: 36px;
    }
    .yabro-widget .game-start-btn-widget {
        padding: 8px 12px;
        font-size: 12px;
        margin-left: 0;
        letter-spacing: 0.2px;
    }
}

@media (max-width: 764px) {
    #toTop {
        bottom: 120px;
    }
}