html, body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow-x: hidden;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    overflow-x: hidden;
    overflow-y: auto;
}

img {
    max-width: 100%;
    height: auto;
    image-rendering: auto;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: block;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
    will-change: auto;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
}

.bg-image {
    width: 40%;
    min-width: 40%;
    height: auto;
    max-height: 100vh;
    object-fit: contain;
    object-position: center;
    display: block;
    image-rendering: auto;
    backface-visibility: hidden;
}

.logo-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 30%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.logo {
    width: auto;
    min-width: 0;
    height: auto;
    object-fit: contain;
    object-position: center;
    image-rendering: auto;
    backface-visibility: hidden;
    display: block;
}
.logo:first-child {
    width: 50%;
}
.logo:nth-child(2),
.logo:nth-child(3) {
    width: 90%;
}
.logo:nth-child(3) {
    margin-top: -35px;
}
.scratch-text-container {
    position: absolute;
    top: 29%;
    left: 35%;
    transform: translate(-75%, -50%);
    z-index: 10;
    pointer-events: none;
    width: 50%;
    max-width: 50%;
}
.scratch-text {
    margin: 0;
    padding: 0;
    color: #14495e;
    font-size: 25px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    white-space: nowrap;
    text-shadow: 
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff,
        0 0 3px rgba(255, 255, 255, 0.8),
        0 2px 4px rgba(0, 0, 0, 0.3);
    text-align: right;
    letter-spacing: 1px;
}
.grid-wrapper {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 25%;
    max-width: calc(40% - 40px);
    pointer-events: none;
}
.grid-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    z-index: 1;
    pointer-events: none;
}
.dragon-layer-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dragon-layer-bg.show {
    opacity: 1;
    visibility: visible;
}

.dragon-layer-bg img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
}

.dragon-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dragon-overlay.show {
    opacity: 1;
    visibility: visible;
}

.dragon-overlay img {
    width: 100%;
    height: auto;
    max-width: 120%;
    object-fit: contain;
    display: block;
}

.grid-container {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    padding: 15px;
    box-sizing: border-box;
    pointer-events: auto;
    z-index: 2;
    background: none;
    min-height: fit-content;
}

.scratch-text-overlay {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: 80%;
    height: auto;
    z-index: 4;
    pointer-events: none;
    image-rendering: auto;
    backface-visibility: hidden;
}

.layer-container {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 20px;
    width: 50%;
    max-width: 600px;
    pointer-events: none;
    z-index: 5;
}

.layer-left,
.layer-right {
    width: auto;
    min-width: 0;
    height: auto;
    max-width: 180px;
    min-width: 150px;
    max-height: 300px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
    image-rendering: auto;
    backface-visibility: hidden;
}

.grid-item {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: pointer;
    background-image: url('./image/Box/whie-box.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.grid-item.revealed {
    cursor: pointer;
}

.grid-item img {
    width: 100%;
    min-width: 100%;
    height: 100%;
    min-height: 100%;
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease;
    image-rendering: auto;
    backface-visibility: hidden;
}

.scratch-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.pop-out-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.pop-out-backdrop.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.pop-out-tryagain {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.pop-out-tryagain.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.pop-out-tryagain img {
    max-width: 280px;
    min-width: 200px;
    width: auto;
    height: auto;
    display: block;
    image-rendering: auto;
    backface-visibility: hidden;
}

.tryagain-button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    margin-top: -10px;
}


.tryagain-button:active {
    transform: scale(0.95);
}

.tryagain-button img {
    max-width: 220px;
    min-width: 150px;
    width: auto;
    height: auto;
    display: block;
    image-rendering: auto;
    backface-visibility: hidden;
}

.pop-out-win {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.pop-out-win.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.pop-out-win img {
    max-width: 280px;
    min-width: 200px;
    width: auto;
    height: auto;
    display: block;
    image-rendering: auto;
    backface-visibility: hidden;
}

.pop-out-win .money-amount {
    max-width: 120px;
    min-width: 80px;
    width: auto;
}

.pop-out-win .win-prize {
    max-width: 320px;
    min-width: 240px;
    width: auto;
}

.btn-win {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    margin-top: -10px;
}

.download-link,
.tg-link {
    display: inline-block;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    pointer-events: auto;
    position: relative;
    z-index: 1001;
}

.btn-win img {
    max-width: 280px;
    min-width: 200px;
    width: auto;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
    image-rendering: auto;
    backface-visibility: hidden;
}


.btn-win img:active {
    transform: scale(0.95);
}

/* Tablet/iPad - use desktop styles */
@media (min-width: 481px) and (max-width: 1024px) {
    .bg-image {
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 100vh;
        object-fit: contain;
    }
    
    .logo-container {
        width: 70%;
        top: 15px;
    }
        
    .logo {
        max-width: 100%;
    }
    
    .logo:nth-child(3) {
        margin-top: -25px;
    }
    
    .grid-wrapper {
        width: 75%;
        max-width: calc(70% - 30px);
        left: 50%;
        transform: translate(-50%, -50%);
        top: 52%;
    }
    
    .scratch-text-overlay {
        top: -75px;
        max-width: 75%;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .grid-container {
        width: 100%;
        top: 0;
        max-width: 100%;
        margin: 0 auto;
        gap: 8px;
        padding: 15px;
    }
    
    .scratch-text-container {
        top: 29%;
        left: 31%;
        transform: translate(-75%, -50%);
        width: 50%;
        max-width: 50%;
    }
    
    .scratch-text {
        font-size: 35px;
    }
    
    .layer-container {
        width: 50%;
        max-width: 600px;
        gap: 30px;
        bottom: 40px;
    }
    
    .layer-left,
    .layer-right {
        max-width: 260px;
        max-height: 300px;
    }
    
    .pop-out-tryagain {
        gap: 12px;
    }
    
    .pop-out-tryagain img {
        max-width: 380px;
        min-width: 280px;
    }
    
    .tryagain-button img {
        max-width: 300px;
        min-width: 220px;
    }
    
    .pop-out-win {
        gap: 12px;
    }
    
    .pop-out-win img {
        max-width: 380px;
        min-width: 280px;
    }
    
    .pop-out-win .money-amount {
        max-width: 140px;
        min-width: 100px;
    }
    
    .pop-out-win .win-prize {
        max-width: 280px;
        min-width: 250px;
    }
    
    .btn-win {
        gap: 10px;
        margin-top: -10px;
    }
    
    .btn-win img {
        max-width: 350px;
        min-width: 280px;
    }
}

/* Small mobile devices */
@media (max-width: 360px) {
    .logo-container {
        top: 5px;
        padding: 2px;
    }
    
    .logo {
        max-width: 75%;
    }
    
    .grid-wrapper {
        width: 95%;
        max-width: calc(100% - 10px);
        left: 50%;
        transform: translate(-50%, -50%);
        top: 55%;
    }
    
    .scratch-text-overlay {
        top: -40px;
        max-width: 65%;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .grid-container {
        gap: 5px;
        padding: 8px;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }
    
    .pop-out-tryagain img {
        max-width: 250px;
        min-width: 180px;
    }
    
    .tryagain-button img {
        max-width: 180px;
        min-width: 130px;
    }
    
    .pop-out-win img {
        max-width: 220px;
        min-width: 160px;
    }
    
    .pop-out-win .money-amount {
        max-width: 100px;
        min-width: 70px;
    }
    
    .pop-out-win .win-prize {
        max-width: 240px;
        min-width: 180px;
    }
    
    .btn-win img {
        max-width: 200px;
        min-width: 150px;
    }
}

/* Landscape orientation for mobile */
@media (max-width: 480px) and (orientation: landscape) {
    .logo-container {
        top: 5px;
        padding: 2px;
    }
    
    .grid-wrapper {
        width: 50%;
        max-width: calc(60% - 20px);
        left: 50%;
        transform: translate(-50%, -50%);
        top: 50%;
    }
    
    .grid-container {
        top: 0;
        gap: 6px;
        padding: 10px;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }
    
    .scratch-text-overlay {
        left: 50%;
        transform: translateX(-50%);
    }
    
    .pop-out-tryagain,
    .pop-out-win {
        top: 45%;
    }
    
    .pop-out-tryagain img,
    .pop-out-win img {
        max-width: 300px;
        min-width: 220px;
    }
    
    .pop-out-win .money-amount {
        max-width: 120px;
        min-width: 90px;
    }
    
    .pop-out-win .win-prize {
        max-width: 300px;
        min-width: 240px;
    }
    
    .btn-win img {
        max-width: 260px;
        min-width: 200px;
    }
}

/* Large screens */
@media (min-width: 1025px) {
    .grid-wrapper {
        width: 25%;
        max-width: calc(40% - 40px);
    }
    
    .scratch-text-overlay {
        max-width: 80%;
    }
}

/* Mobile responsive */
@media (max-width: 480px) {
    .bg-image {
        width: 100%;
        height: 100vh;
        min-height: 100vh;
        object-fit: cover;
    }
    
    .logo-container {
        width: 100%;
        padding: 3px;
        object-fit: cover;
        box-sizing: border-box;
        top: 10px;
    }
    
    .logo {
        max-width: 78%;
    }
    
    .logo:nth-child(3) {
        margin-top: -20px;
    }
    
    .scratch-text-container {
        top: 32%;
        left: 26%;
        transform: translate(-75%, -50%);
        width: 50%;
        max-width: 50%;
    }
    
    .scratch-text {
        font-size: 20px;
        font-weight: bold;
        font-family: Arial, sans-serif;
        text-shadow: 
            -1px -1px 0 #fff,
            1px -1px 0 #fff,
            -1px 1px 0 #fff,
            1px 1px 0 #fff,
            0 0 2px rgba(255, 255, 255, 0.8),
            0 1px 3px rgba(0, 0, 0, 0.3);
        letter-spacing: 0.5px;
    }
    
    .grid-wrapper {
        width: 90%;
        max-width: calc(100% - 20px);
        left: 50%;
        transform: translate(-50%, -50%);
        top: 55%;
    }
    
    .scratch-text-overlay {
        top: -50px;
        max-width: 70%;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .grid-container {
        width: 100%;
        top: 0;
        max-width: 100%;
        gap: 6px;
        padding: 10px;
        margin: 0 auto;
    }
    
    .grid-item {
        min-width: 0;
    }
    
    .grid-item img {
        min-width: 0;
    }
    
    .layer-container {
        width: 90%;
        max-width: 500px;
        gap: 10px;
        bottom: 10px;
    }
    
    .layer-left,
    .layer-right {
        max-width: 120px;
        max-height: 180px;
    }
    
    .pop-out-tryagain {
        top: 49%;
        gap: 10px;
    }
    
    .pop-out-tryagain img {
        max-width: 280px;
        min-width: 200px;
    }
    
    .tryagain-button {
        margin-top: -5px;
    }
    
    .tryagain-button img {
        max-width: 200px;
        min-width: 150px;
    }
    
    .pop-out-win {
        top: 49%;
        gap: 10px;
    }
    
    .pop-out-win img {
        max-width: 250px;
        min-width: 180px;
    }
    
    .pop-out-win .money-amount {
        max-width: 110px;
        min-width: 85px;
    }
    
    .pop-out-win .win-prize {
        max-width: 280px;
        min-width: 180px;
    }
    
    .btn-win {
        gap: 10px;
        margin-top: -5px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .btn-win img {
        max-width: 240px;
        min-width: 180px;
    }
    
    .download-link,
    .tg-link {
        z-index: 1002;
    }
}