/* Native RoomPlay already is the installed app; never advertise PWA installation. */
.roomplay-ios-app .install-prompt-banner,
.roomplay-android-app .install-prompt-banner {
    display: none !important;
}

/* Install prompt banner — bottom sheet */
.install-prompt-banner {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    padding: 0 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    justify-content: center;
    pointer-events: none;
}

.install-prompt-banner.active {
    display: flex;
}

.install-prompt-card {
    pointer-events: auto;
    background: linear-gradient(135deg, #252b4a 0%, #1a2140 100%);
    border-radius: 20px;
    padding: 16px;
    max-width: 430px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
    animation: install-slide-up 0.4s ease-out;
}

@keyframes install-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.install-prompt-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    flex-shrink: 0;
}

.install-prompt-text {
    flex: 1;
    min-width: 0;
}

.install-prompt-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 2px;
}

.install-prompt-subtitle {
    font-size: 12px;
    color: #8892b0;
    line-height: 1.3;
}

.install-prompt-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(135deg, #ff3b6f, #cc2f59);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.install-prompt-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #8892b0;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* iOS: Safari has no install API, so the card itself shows the taps. */
.install-prompt-banner-ios .install-prompt-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

.install-prompt-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.install-prompt-head .install-prompt-close {
    align-self: flex-start;
}

.install-prompt-steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.install-prompt-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.install-prompt-chip svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: #4da3ff;
    fill: none;
}

.install-prompt-chip-icon svg {
    fill: #4da3ff;
    stroke: none;
}

.install-prompt-sep {
    color: #8892b0;
    font-size: 16px;
    font-weight: 700;
}

/* Arrow toward Safari's bottom toolbar: Share sits mid-bar, iOS 26 compact puts ••• at the right. */
.install-prompt-safari {
    padding-bottom: 44px;
}

.install-prompt-arrow {
    position: absolute;
    bottom: 4px;
    left: 50%;
    width: 32px;
    height: 32px;
    margin-left: -16px;
    animation: install-arrow-bounce 1.2s ease-in-out infinite;
}

.install-prompt-safari-26 .install-prompt-arrow {
    left: auto;
    right: 18px;
    margin-left: 0;
}

.install-prompt-arrow svg {
    width: 100%;
    height: 100%;
    stroke: #ff3b6f;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

@keyframes install-arrow-bounce {
    0%, 100% { transform: translateY(-4px); }
    50% { transform: translateY(4px); }
}

/* A finger taps each chip in turn: chip i starts at i seconds of a 4 s loop. */
.install-prompt-chip {
    animation: install-chip-press 4s ease-in-out infinite;
    animation-delay: calc(var(--i, 0) * 1s);
}

.install-prompt-chip .install-prompt-finger {
    position: absolute;
    right: -4px;
    bottom: -6px;
    width: 22px;
    height: 22px;
    fill: rgba(255, 255, 255, 0.85);
    stroke: rgba(13, 19, 41, 0.35);
    stroke-width: 1.5;
    opacity: 0;
    pointer-events: none;
    animation: install-finger-tap 4s ease-in-out infinite;
    animation-delay: calc(var(--i, 0) * 1s);
}

@keyframes install-chip-press {
    0%, 6% { transform: scale(1); background: rgba(255, 255, 255, 0.1); }
    12% { transform: scale(0.93); background: rgba(77, 163, 255, 0.35); }
    20% { transform: scale(1); background: rgba(77, 163, 255, 0.22); }
    26%, 100% { transform: scale(1); background: rgba(255, 255, 255, 0.1); }
}

@keyframes install-finger-tap {
    0% { opacity: 0; transform: translate(10px, 10px) scale(1.3); }
    7% { opacity: 1; transform: translate(0, 0) scale(1.1); }
    12% { opacity: 1; transform: translate(0, 0) scale(0.8); }
    20% { opacity: 1; transform: translate(0, 0) scale(1); }
    26%, 100% { opacity: 0; transform: translate(6px, 6px) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .install-prompt-card,
    .install-prompt-arrow,
    .install-prompt-chip,
    .install-prompt-chip .install-prompt-finger { animation: none; }
}

/* Modal suppression is immediate, not a banner exit animation. */
.install-prompt-banner[hidden] { display: none !important; }

/* Chrome/Firefox/Edge on iOS: one wide button that hands the page to Safari. */
.install-prompt-safari-open {
    width: 100%;
    padding: 12px 18px;
    font-size: 15px;
    white-space: normal;
}

.install-prompt-btn-done {
    background: rgba(255, 255, 255, 0.12);
}

/* Bottom sheet (A/B install_timing «now»): stays above the catalog's «Есть код комнаты?» row. */
body:has(#join-banner:not(.hidden)) .install-prompt-banner:not(.install-prompt-center),
body:has(#ru-room-control:not([hidden])) .install-prompt-banner:not(.install-prompt-center) {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

/* Large centered card after a finished game (A/B install_timing «after_game»). */
.install-prompt-banner.install-prompt-center {
    top: 0;
    align-items: center;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    background: rgba(8, 12, 28, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: auto;
}

.install-prompt-center .install-prompt-card,
.install-prompt-center.install-prompt-banner-ios .install-prompt-card {
    max-width: 360px;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 28px 22px 20px;
    border-radius: 28px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    animation: install-pop-in 0.38s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes install-pop-in {
    from { transform: translateY(16px) scale(0.94); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.install-prompt-center .install-prompt-head {
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.install-prompt-center .install-prompt-icon {
    width: 88px;
    height: 88px;
    border-radius: 22px;
    box-shadow: 0 12px 28px rgba(255, 59, 111, 0.28);
}

.install-prompt-center .install-prompt-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 6px;
}

.install-prompt-center .install-prompt-subtitle {
    font-size: 15px;
    color: #aeb7d3;
}

.install-prompt-center .install-prompt-lead {
    margin: 0 0 6px;
    font-size: 15px;
    line-height: 1.35;
    color: #ffffff;
}

/* The lead sits above the Safari hint in the centered card. */
.install-prompt-center .install-prompt-text {
    display: flex;
    flex-direction: column;
}

.install-prompt-center .install-prompt-title { order: 0; }
.install-prompt-center .install-prompt-lead { order: 1; }
.install-prompt-center .install-prompt-subtitle { order: 2; }

.install-prompt-center .install-prompt-close {
    display: none;
}

.install-prompt-center .install-prompt-steps {
    justify-content: center;
}

.install-prompt-center .install-prompt-btn {
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 800;
}

.install-prompt-later {
    width: 100%;
    padding: 12px 16px;
    border: 0;
    border-radius: 30px;
    background: transparent;
    color: #8892b0;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.install-prompt-later:active {
    transform: scale(0.97);
}

/* The Safari arrow still points at the toolbar below the dimmed page. */
.install-prompt-center.install-prompt-safari .install-prompt-arrow {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

/* iPhone outside Russia (after_game group): a link to the native app in the App Store. */
.install-prompt-app-store-open {
    display: block;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
}
