/* ==================== CRASH GAME ==================== */

#screenCrash {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 80px 0 80px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    background: #08090d;
    min-height: 100vh;
    min-height: 100dvh;
}

#screenCrash.active { display: flex !important; }

.crash-container {
    width: 100%;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.crash-scene {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    gap: 10px;
}

.crash-rocket-area {
    width: 100%;
    height: calc(100vh - 200px);
    min-height: 300px;
    max-height: 450px;
    position: relative;
    overflow: hidden;
    background: radial-gradient(ellipse at center bottom, rgba(240, 136, 62, 0.05) 0%, transparent 70%);
}

/* ==================== CRASH GUY (GIF) ==================== */

.crash-guy {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: auto;
    z-index: 5;
    object-fit: contain;
}

/* ==================== ОЖИДАНИЕ (ПРОГРЕСС-БАР) ==================== */

.crash-waiting-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 10;
    width: 75%;
}

.crash-waiting-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(240, 136, 62, 0.5));
    animation: logo-pulse 2s ease-in-out infinite;
}

@keyframes logo-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.crash-waiting-text {
    color: #f5c842;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: center;
    line-height: 1.2;
    text-transform: uppercase;
    text-shadow: 0 0 15px rgba(245, 200, 66, 0.3);
}

.crash-progress-bar {
    width: 100%;
    height: 11px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.crash-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f5c842, #f0883e);
    border-radius: 6px;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(240, 136, 62, 0.4);
}

.crash-multiplier {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    color: #ffffff;
    font-size: 42px;
    font-weight: 800;
    z-index: 10;
    transition: all 0.3s ease;
    letter-spacing: 1px;
    text-shadow:
        0 0 6px #ffffff,
        0 0 20px #f5c842,
        0 0 40px #f0883e,
        0 0 60px #f0883e;
}

.crash-multiplier.crashed {
    color: #ffffff;
    text-shadow:
        0 0 6px #ffffff,
        0 0 20px #ff4444,
        0 0 40px #ff4444,
        0 0 60px #ff4444;
}

.crash-text {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 44px;
    font-weight: 800;
    z-index: 10;
    animation: crash-pop 0.5s ease-out;
    letter-spacing: 2px;
    text-shadow:
        0 0 6px #ffffff,
        0 0 20px #ff4444,
        0 0 40px #ff4444,
        0 0 60px #ff4444;
}

@keyframes crash-pop {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    60% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Падающие звёзды */
.scene-star {
    position: absolute;
    top: -50px;
    width: 2px;
    height: 2px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 
        0 0 4px 1px rgba(255, 255, 255, 0.6),
        0 0 8px 2px rgba(255, 255, 255, 0.3),
        0 0 12px 3px rgba(255, 255, 255, 0.15);
    animation: star-fall linear infinite;
    z-index: 4;
}

.scene-star::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 10px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), transparent);
    border-radius: 50%;
}

@keyframes star-fall {
    0% {
        transform: translateY(-50px) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(550px) translateX(-30px);
        opacity: 0;
    }
}

.crash-currency-icon {
    width: 12px;
    height: 12px;
    object-fit: contain;
    vertical-align: middle;
    margin-left: 2px;
}

.crash-gift-bet-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 2px;
}

.crash-result-overlay {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 16px;
    padding: 24px 32px;
    z-index: 20;
    border: 2px solid rgba(255, 215, 0, 0.3);
    animation: result-fade-in 0.3s ease;
    white-space: nowrap;
}

.crash-result-text {
    color: #FFD700;
    font-size: 18px;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

/* ==================== ЛЕНТА ИСТОРИИ ==================== */

.crash-history-row {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    box-sizing: border-box;
    flex-direction: row;
}

.crash-history-row::-webkit-scrollbar {
    display: none;
}

.crash-history-empty {
    color: #5a6070;
    font-size: 12px;
    text-align: center;
    width: 100%;
    padding: 8px;
}

/* Обычные иксы — серые */
.crash-history-item {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
    transition: all 0.15s ease;
    cursor: default;
    user-select: none;
    background: rgba(255, 255, 255, 0.06);
    color: #8a93a8;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.crash-history-item:active {
    transform: scale(0.95);
}

/* Текущий икс — оранжевый, самый левый */
.crash-history-item.current {
    background: linear-gradient(135deg, #f0883e, #f5c842, #ffd700);
    color: #0a0f1a;
    font-weight: 800;
    border: 1px solid rgba(245, 200, 66, 0.5);
    box-shadow: 
        0 0 10px rgba(240, 136, 62, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.crash-bet-btn {
    width: calc(100% - 24px);
    margin: 0 12px;
    padding: 14px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 15px;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #f0883e, #f5c842, #ffd700);
    color: #0a0f1a;
    border: 1px solid #f5c84260;
    box-shadow: 0 0 25px rgba(240, 136, 62, 0.4);
    transition: all 0.25s;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

.crash-bet-btn:active { transform: scale(0.98); }
.crash-bet-btn:disabled { 
    opacity: 0.4; 
    cursor: not-allowed; 
    box-shadow: none;
}

.crash-players-list {
    width: calc(100% - 24px);
    margin: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-sizing: border-box;
}

.crash-players-empty {
    color: #5a6070;
    font-size: 12px;
    text-align: center;
    padding: 12px;
}

.crash-player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Анимация появления нового игрока */
.crash-player-row.player-new {
    animation: player-appear 0.4s ease-out;
}

@keyframes player-appear {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    60% {
        opacity: 1;
        transform: translateY(2px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.crash-player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.04);
}

.crash-player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.crash-player-info {
    flex: 1;
    min-width: 0;
}

.crash-player-name {
    color: #d0daf0;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crash-player-bet {
    color: #6b7daa;
    font-size: 11px;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.crash-player-status {
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.crash-player-status.win {
    color: #00e676;
}

.crash-player-status.lose {
    color: #ff4444;
}

.crash-player-status.playing {
    color: #f5c842;
}

.crash-bet-modal-overlay {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 450px;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    display: none;
    justify-content: center;
    align-items: flex-end;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.crash-bet-modal-overlay.show {
    display: flex;
    opacity: 1;
}

.crash-bet-modal-card {
    width: 100%;
    max-width: 450px;
    max-height: 70vh;
    background: rgba(10, 12, 18, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px 20px 0 0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: none;
    padding: 28px 24px 36px 24px;
    text-align: center;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    will-change: transform;
    box-sizing: border-box;
}

.crash-bet-modal-overlay.show .crash-bet-modal-card {
    transform: translateY(0);
}

.crash-modal-title {
    color: #ffffff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}

.crash-modal-tabs {
    display: flex;
    background: rgba(120, 120, 128, 0.16);
    border-radius: 10px;
    padding: 2px;
    gap: 0;
    width: 100%;
    flex-shrink: 0;
}

.crash-modal-tab {
    flex: 1;
    min-height: 36px;
    padding: 10px 4px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
    border: none;
    cursor: pointer;
    background: transparent;
    color: #6b7daa;
    text-transform: uppercase;
    letter-spacing: 1px;
    -webkit-tap-highlight-color: transparent;
    text-align: center;
    position: relative;
    z-index: 1;
    transition: all 0.3s;
}

.crash-modal-tab.active {
    background: linear-gradient(135deg, #f0883e, #f5c842);
    color: #0a0f1a;
    box-shadow: 0 0 12px rgba(245, 200, 66, 0.3);
}

.crash-bet-input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 0;
}

.crash-bet-input {
    width: 140px;
    background: transparent;
    border: none;
    padding: 8px 4px;
    color: #ffffff;
    font-size: 40px;
    font-weight: 700;
    text-align: center;
    outline: none;
}

.crash-bet-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.crash-bet-currency-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.crash-modal-confirm-btn {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 15px;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #f0883e, #f5c842, #ffd700);
    color: #0a0f1a;
    border: 1px solid #f5c84260;
    box-shadow: 0 0 25px rgba(240, 136, 62, 0.4);
    transition: all 0.25s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.crash-modal-confirm-btn:active {
    transform: scale(0.98);
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
}

.crash-gifts-empty {
    color: #6b7daa;
    font-size: 14px;
    text-align: center;
    padding: 40px 20px;
}

.crash-gifts-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.crash-gift-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.crash-gift-item:active {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.crash-gift-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.25));
    flex-shrink: 0;
}

.crash-gift-info {
    flex: 1;
    min-width: 0;
}

.crash-gift-name {
    color: #d0daf0;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crash-gift-price {
    color: #ffd700;
    font-size: 11px;
    font-weight: 700;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 2px;
}

@keyframes result-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}