* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-image: url('images/background-banner-blue.png');
}

body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    height: 100vh;
    background-color: #1a237e;
    background-image: var(--bg-image);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
}

/* Mobile viewport fix */
@media (max-width: 768px) {
    body {
        overflow: hidden;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }
}

/* Поддержка высоких DPI экранов */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .dice-img, .logo img, .frame-bg, .bonus-card-img {
        /* Улучшенное сглаживание для Retina дисплеев */
        image-rendering: auto;
        image-rendering: -webkit-optimize-contrast;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Background patterns removed - using only background image */

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease-in-out;
    z-index: 1;
}

/* Hide screens while loader is active */
body:not(.loaded) .screen {
    opacity: 0 !important;
    visibility: hidden !important;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.background {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Десктопное центрирование и контролируемая ширина контента */
@media (min-width: 1024px) {
    .chests-container,
    .bonus-container {
        max-width: 860px;
        width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
    .chest-subtitle {
        max-width: 900px;
        margin-left: auto;
        margin-right: auto;
        line-height: 0.95;
        word-break: keep-all;
        hyphens: none;
    }
    .chest-subtitle .highlight-777 { line-height: 0.95; }
    .chests-grid { max-width: 860px; }
    .sponsor-banner { width: 100%; }
    .banner-img { max-width: 720px; width: 80%; }
}

.logo {
    margin-bottom: 20px;
    z-index: 10;
}

.logo img {
    height: 140px;
    width: auto;
    /* Улучшение качества SVG на всех устройствах */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}


/* Chests UI */
.chests-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 420px;
    width: 90%;
}

.chest-subtitle {
    font-family: 'Lilita One', cursive;
    font-weight: 400;
    font-style: normal;
    font-size: 68px;
    line-height: 100%;
    letter-spacing: 0;
    text-align: center;
    text-transform: uppercase;
    color: #ffffff;
}

.chest-subtitle .highlight-777 {
    font-family: 'Lilita One', cursive;
    font-weight: 400;
    font-style: normal;
    font-size: 68px;
    line-height: 100%;
    letter-spacing: 0;
    text-align: center;
    color: #FBFF06 !important;
    -webkit-text-fill-color: #FBFF06;
}

.highlight-777-img {
    display: inline-block;
    vertical-align: middle;
    height: 1.5em;
    width: auto;
    transform: translateY(-2px);
}

.chests-grid {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    gap: 2vw;
    width: fit-content;
    max-width: 90vw;
    padding: 20px;
    box-sizing: border-box;
    background: linear-gradient(135deg, #62D7FD 0%, #1C95FE 100%);
    border-radius: 18px;
    border: 4px solid white;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    margin: 0 auto;
}

/* Sponsor Banner */
.sponsor-banner {
    width: 100%;
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.banner-img {
    width: 90%;
    max-width: 90%;
    height: auto;
    display: block;
    /* Улучшение качества SVG */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.chest-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1vw;
    justify-content: flex-start;
    min-height: min(28vw, 180px);
    width: min(24vw, 130px);
    flex: 0 0 auto;
    position: relative;
}
.chest-label {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ouvrir-btn-img {
    max-width: min(22vw, 120px);
    height: auto;
    display: block;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.ouvrir-btn-img:hover {
    transform: translateY(-2px);
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.4));
}

.ouvrir-btn-img:active {
    transform: translateY(0);
}

/* Arrow animation removed - using image button now */

.chest {
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(24vw, 130px);
    height: min(24vw, 130px);
    position: relative;
    overflow: visible;
    margin: 0 auto;
}

/* Glow background effect after opening */
.chest::after {
    content: '';
    position: absolute;
    inset: -12px;
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
    filter: blur(14px);
}

.chest.opened-empty::after {
    background: radial-gradient(circle, rgba(200,200,200,0.55) 0%, rgba(160,160,160,0.25) 45%, rgba(0,0,0,0) 70%);
    opacity: 1;
}

.chest.opened-prize::after {
    background: radial-gradient(circle, rgba(255,215,0,0.65) 0%, rgba(255,176,0,0.35) 45%, rgba(0,0,0,0) 70%);
    opacity: 1;
}

.chest:focus-visible {
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.8);
    border-radius: 8px;
}

.chest:hover { transform: translateY(-2px); }
.chest:active { transform: translateY(0); }

.chest.opening { animation: chest-pop 250ms ease forwards; }
.chest.shake { animation: chest-shake 300ms ease; }

.chest-img {
    width: min(24vw, 130px);
    height: min(24vw, 130px);
    object-fit: contain;
    object-position: center;
    display: block;
    filter: drop-shadow(0 8px 20px rgba(0,0,0,0.35));
    transition: transform 0.2s ease;
    position: relative;
    z-index: 1;
    margin: 0 auto;
}

/* Смещение карточки-приза вверх, чтобы выравнивалась по сундуку */
.chest-img.prize {
    transform: translateY(-4%);
}

.hint {
    color: #ffffff;
    opacity: 0.9;
    font-weight: bold;
    letter-spacing: 0.5px;
}

@keyframes chest-pop {
    0% { transform: scale(1); }
    60% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes chest-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    50% { transform: translateX(3px); }
    75% { transform: translateX(-2px); }
}

/* Prize display over chest */
.chest-prize {
    position: absolute;
    top: -70px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.chest-prize.show {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.chest-prize img {
    width: min(30vw, 160px);
    height: auto;
    display: block;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8)) drop-shadow(0 0 40px rgba(255, 215, 0, 0.4));
    animation: prizeFloat 2s ease-in-out infinite alternate;
}

/* Стили для reload изображения над пустыми сундуками */
.chest-prize img[src*="reload.png"] {
    width: min(14vw, 72px);
    filter: drop-shadow(0 0 15px rgba(100, 149, 237, 0.6)) drop-shadow(0 0 30px rgba(100, 149, 237, 0.3));
    animation: reloadFloat 2s ease-in-out infinite alternate;
}

@keyframes reloadFloat {
    0% {
        transform: translateY(0px) rotate(0deg);
        filter: drop-shadow(0 0 15px rgba(100, 149, 237, 0.6)) drop-shadow(0 0 30px rgba(100, 149, 237, 0.3));
    }
    100% {
        transform: translateY(-3px) rotate(5deg);
        filter: drop-shadow(0 0 20px rgba(100, 149, 237, 0.8)) drop-shadow(0 0 40px rgba(100, 149, 237, 0.5));
    }
}

@keyframes prizeFloat {
    0% {
        transform: translateY(0px);
        filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8)) drop-shadow(0 0 40px rgba(255, 215, 0, 0.4));
    }
    100% {
        transform: translateY(-5px);
        filter: drop-shadow(0 0 30px rgba(255, 215, 0, 1)) drop-shadow(0 0 60px rgba(255, 215, 0, 0.6));
    }
}



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


/* Bonus screen styles */
.bonus-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 400px;
    width: 90%;
}

.bonus-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    width: 100%;
    max-width: 350px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    text-align: center;
}

.bonus-content {
    margin: 30px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.vip-card {
    width: 200px;
    height: 120px;
    background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(21,101,192,0.4);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: white;
}

.card-number {
    font-size: 36px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.card-logo img {
    height: 25px;
    filter: brightness(0) invert(1);
}

.wild-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ffd700;
    color: #1565c0;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: bold;
}

.bonus-text {
    text-align: center;
}

.vip-label {
    font-size: 24px;
    font-weight: bold;
    color: #1565c0;
    margin-bottom: 5px;
}

.bonus-label {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.bonus-btn {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    border: 3px solid #333;
    border-radius: 50px;
    padding: 15px 30px;
    font-size: 24px;
    font-weight: bold;
    font-family: 'Changa One', cursive;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    margin: 0 auto;
}

.bonus-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.bonus-btn:active {
    transform: translateY(-1px);
}

/* Final bonus screen styles */
.final-bonus-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
    max-width: 400px;
    background: linear-gradient(135deg, #62D7FD 0%, #1C95FE 100%);
    border-radius: 18px;
    border: 4px solid white;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    padding: 16px;
}

.final-bonus-image {
    width: 100%;
    display: flex;
    justify-content: center;
}

.bonus-card-img {
    max-width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.6)) drop-shadow(0 0 60px rgba(255, 215, 0, 0.3));
    animation: imageGlow 3s ease-in-out infinite alternate;
    /* Улучшение качества бонусной карты */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Убираем отступы вокруг бонус-карты на финальном экране */
.final-bonus-card {
    padding-top: 8px;
    padding-bottom: 8px;
}

@keyframes imageGlow {
    0% {
        filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.6)) drop-shadow(0 0 60px rgba(255, 215, 0, 0.3));
    }
    100% {
        filter: drop-shadow(0 0 40px rgba(255, 215, 0, 0.8)) drop-shadow(0 0 80px rgba(255, 215, 0, 0.5));
    }
}

.final-bonus-text {
    font-family: 'Lilita One', cursive;
    font-weight: 400;
    font-style: normal;
    font-size: 72px;
    line-height: 100%;
    letter-spacing: 0;
    text-align: center;
    color: #ffffff;
    margin: 0;
}

.final-bonus-text .highlight-bonus {
    color: #FBFF06 !important;
    -webkit-text-fill-color: #FBFF06;
}

@keyframes goldGlow {
    0% {
        text-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.4);
        filter: drop-shadow(0 4px 8px rgba(255, 215, 0, 0.3));
    }
    100% {
        text-shadow: 0 0 40px rgba(255, 215, 0, 1), 0 0 80px rgba(255, 215, 0, 0.6);
        filter: drop-shadow(0 6px 12px rgba(255, 215, 0, 0.5));
    }
}

/* Десктопное центрирование — в самом конце для гарантированного переопределения */
@media (min-width: 1024px) {
    .screen { align-items: center; justify-content: center; }
    .background { align-items: center; justify-content: center; }
    .logo { width: 100%; display: flex; justify-content: center; }
    .logo img { margin: 0 auto; display: block; }

    .chests-container,
    .bonus-container {
        max-width: 920px;
        width: 100%;
        margin-left: auto;
        margin-right: auto;
        align-items: center;
        text-align: center;
    }

    .chest-subtitle {
        max-width: 880px;
        margin-left: auto;
        margin-right: auto;
        line-height: 0.95;
        word-break: keep-all;
        hyphens: none;
    }
    .chest-subtitle .highlight-777 { line-height: 0.95; }

    .chests-grid {
        max-width: 920px;
        margin-left: auto;
        margin-right: auto;
    }

    .sponsor-banner { width: 100%; justify-content: center; }
    .banner-img { width: 60%; max-width: 640px; margin-left: auto; margin-right: auto; }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .chest-subtitle { font-size: 48px; }
    .chest-subtitle .highlight-777 { font-size: 48px; }
    .screen {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        align-items: flex-start;
        padding-top: env(safe-area-inset-top, 20px);
    }
    
    /* Исправление позиционирования лоадера на мобильных */
    .loader {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        background-color: #1a237e !important;
        background-image: url('images/background-banner-blue.png') !important;
        background-position: center !important;
        background-size: cover !important;
        background-repeat: no-repeat !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 9999 !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        transform: none !important;
        -webkit-transform: none !important;
    }
    
    
    
    .background {
        justify-content: flex-start;
        padding-top: 0;
        min-height: 100vh;
    }
    
    .logo {
        margin-top: 0;
        margin-bottom: 20px;
    }
    
    .logo img {
        height: 120px;
    }
    
    .chests-container,
    .bonus-container {
        width: 95%;
        gap: 20px;
        margin-top: 0;
        box-sizing: border-box;
    }
    
    .chests-grid {
        padding: 15px;
        gap: 1.5vw;
    }
    
    .chest-prize {
        top: -60px;
    }
    
    .chest-prize img {
        width: min(26vw, 120px);
    }
    .chest-wrap { 
        min-height: min(30vw, 180px);
        width: min(26vw, 140px);
    }
    .chest-img { width: min(28vw, 120px); height: min(28vw, 120px); }
    .chest {
        width: min(28vw, 120px);
        height: min(28vw, 120px);
    }
    .chest-label { font-size: 16px; }
    .ouvrir-btn-img { max-width: min(22vw, 120px); }
    
    /* Sponsor Banner Mobile */
    .sponsor-banner {
        margin-top: 15px;
    }
    
    
    .final-bonus-text {
        font-size: 44px;
    }
    
    
    .bonus-btn {
        padding: 12px 25px;
        font-size: 16px;
    }
    

    
    .vip-card {
        width: 180px;
        height: 110px;
    }
    
    .card-number {
        font-size: 32px;
    }
    
    .vip-label {
        font-size: 20px;
    }
    .chest-prize img[src*="reload.png"] {
        width: min(14vw, 64px);
    }
    .chest-prize.empty { top: -45px; }
}

@media (max-width: 480px) {
    .chest-subtitle { font-size: 40px; }
    .chest-subtitle .highlight-777 { font-size: 40px; }
    .screen {
        padding-top: env(safe-area-inset-top, 15px);
    }
    
    /* Дополнительное исправление для маленьких экранов */
    .loader {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        background-color: #1a237e !important;
        background-image: url('images/background-banner-blue.png') !important;
        background-position: center !important;
        background-size: cover !important;
        background-repeat: no-repeat !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 9999 !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        transform: none !important;
        -webkit-transform: none !important;
    }
    
    .background {
        padding-top: 0;
    }
    
    .logo {
        margin-top: 0;
    }
    
    .chests-container,
    .bonus-container {
        width: 98%;
        gap: 15px;
        box-sizing: border-box;
    }
    
    .chests-grid {
        padding: 12px;
        gap: 1vw;
    }
    
    .chest-prize {
        top: -55px;
    }
    
    .chest-prize img {
        width: min(22vw, 100px);
    }
    .chest-wrap { 
        min-height: min(35vw, 180px);
        width: min(28vw, 120px);
    }
    .chest-img { 
        width: min(28vw, 120px);
        height: min(28vw, 120px);
    }
    .chest {
        width: min(28vw, 120px);
        height: min(28vw, 120px);
    }
    .chest-label { font-size: 14px; }
    .ouvrir-btn-img { max-width: min(22vw, 120px); }
    
    /* Sponsor Banner Small Mobile */
    .sponsor-banner {
        margin-top: 12px;
    }
    .chest-prize img[src*="reload.png"] {
        width: min(12vw, 56px);
    }
    .chest-prize.empty { top: -42px; }
}

/* Extra small mobile devices */
@media (max-width: 360px) {
    .chest-wrap { 
        min-height: min(40vw, 160px);
        width: min(30vw, 100px);
    }
    .chest-img { 
        width: min(30vw, 100px);
        height: min(30vw, 100px);
    }
    .chest {
        width: min(30vw, 100px);
        height: min(30vw, 100px);
    }
    .ouvrir-btn-img { max-width: min(22vw, 120px); }
    
    .chest-prize {
        top: -48px;
    }
    
    .chest-prize img {
        width: min(20vw, 85px);
    }
    
    .bonus-card {
        padding: 20px;
    }
    
    
    .final-bonus-text {
        font-size: 38px;
    }
    
    
    
    
    .vip-card {
        width: 160px;
        height: 100px;
    }
    
    .card-number {
        font-size: 28px;
    }
    .chest-prize img[src*="reload.png"] {
        width: min(11vw, 48px);
    }
    .chest-prize.empty { top: -38px; }
}

/* Loading animation */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Loader styles */
.loader {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: #1a237e !important;
    background-image: url('images/background-banner-blue.png') !important;
    background-position: center !important;
    background-size: cover !important;
    background-repeat: no-repeat !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    /* Принудительное центрирование */
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    /* Сброс любых трансформаций */
    transform: none !important;
    -webkit-transform: none !important;
}

.loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-logo {
    margin-bottom: 30px;
    animation: logoPulse 2s ease-in-out infinite;
    /* Принудительное центрирование */
    text-align: center;
    width: 100%;
}

.loader-logo img {
    height: 100px;
    width: auto;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loader-text {
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    animation: textFade 1.5s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes textFade {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}



/* Центрирование для экранов <= 720px (переопределяет блок <=768px) */
@media (max-width: 720px) {
    .screen { align-items: flex-start; }
    .background { justify-content: flex-start; padding-top: env(safe-area-inset-top, 20px); }
    .logo { width: 100%; display: flex; justify-content: center; }
    .logo img { margin: 0 auto; display: block; }

    .chests-container,
    .bonus-container {
        max-width: 600px;
        width: 94%;
        margin-left: auto;
        margin-right: auto;
        align-items: center;
        text-align: center;
    }

    .chests-grid {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .sponsor-banner { width: 100%; justify-content: center; }
    .banner-img { width: 80%; max-width: 420px; margin-left: auto; margin-right: auto; }
}

