.game-page {
    width: 100%;
    /* = 1024px (be rong canvas) + 24px le hai ben: khung bao vua khit canvas, khong con vien den 2 ben. */
    max-width: 1048px;
    margin: 18px auto 30px;
    padding: 0 12px;
    box-sizing: border-box;
}

.game-card {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #000;
    border: 3px solid #2f92ba;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}

#unity-container {
    position: relative;
    width: 100%;
    max-width: 1024px;
    margin: 0 auto;
    background: #000;
    line-height: 0;
}

#unity-canvas {
    display: block;
    width: 100%;
    height: auto;
    min-height: 220px;
    margin: 0 auto;
    background: #000;
    outline: none;
    touch-action: none;
}

/* Keep Unity's internal coordinate system at the APK reference size.
   CSS may scale the presentation, but must not resize the game surface. */
#unity-canvas {
    image-rendering: auto;
}

#unity-loading-bar {
    position: absolute;
    z-index: 3;
    top: 50%;
    left: 50%;
    width: min(86%, 420px);
    transform: translate(-50%, -50%);
    padding: 18px 20px;
    box-sizing: border-box;
    color: #fff;
    text-align: center;
    line-height: 1.4;
    background: rgba(5, 20, 31, .92);
    border: 1px solid rgba(110, 211, 255, .7);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
}

#unity-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 10px;
    background: url('/images/nro-bang.png') center / contain no-repeat;
}

#unity-loading-bar p {
    margin: 0 0 12px;
    color: #eaf9ff;
    font-size: clamp(14px, 2.4vw, 18px);
}

#unity-progress-bar-empty {
    width: 100%;
    height: 9px;
    overflow: hidden;
    background: #173746;
    border-radius: 99px;
}

#unity-progress-bar-full {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #23a8e0, #81e5ff);
    border-radius: inherit;
    transition: width .12s linear;
}

#unity-warning {
    position: absolute;
    z-index: 4;
    top: 10px;
    left: 10px;
    right: 10px;
    line-height: 1.35;
}

#unity-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 7px 10px;
    box-sizing: border-box;
    color: #dff7ff;
    background: #126684;
    line-height: 1.2;
}

#unity-webgl-logo {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    background: url('/images/icons/favicon-32x32.png') center / contain no-repeat;
}

#unity-build-title {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
}

#unity-fullscreen-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    background: #2499c5;
    border: 1px solid #7de0ff;
    border-radius: 7px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18);
}

#unity-fullscreen-button:active {
    transform: translateY(1px);
    background: #177da5;
}

#mobile-keyboard-footer-button {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 9px;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    background: #2499c5;
    border: 1px solid #7de0ff;
    border-radius: 7px;
}

.game-note {
    margin: 10px 0 0;
    color: #34596a;
    text-align: center;
    line-height: 1.4;
}

#unity-container:fullscreen,
#unity-container:-webkit-full-screen {
    width: 100vw;
    max-width: none;
    height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #000;
    display: block;
}

#unity-container:fullscreen #unity-canvas,
#unity-container:-webkit-full-screen #unity-canvas {
    width: 100vw !important;
    height: 100vh !important;
    max-height: none;
    max-width: none;
    object-fit: fill;
}

#unity-container:fullscreen #unity-footer,
#unity-container:-webkit-full-screen #unity-footer {
    display: none !important;
}

@media (max-width: 600px) {
    .game-page {
        margin: 8px auto 18px;
        padding: 0 5px;
    }

    .game-card {
        border-width: 2px;
        border-radius: 8px;
    }

    #unity-canvas {
        min-height: 180px;
    }

    #unity-footer {
        min-height: 42px;
        padding: 5px 7px;
    }

    #unity-webgl-logo {
        display: none;
    }

    #unity-build-title {
        font-size: 13px;
    }

    #unity-fullscreen-button {
        min-height: 30px;
        padding: 6px 9px;
        font-size: 12px;
    }

    #mobile-keyboard-footer-button {
        display: inline-flex;
        min-height: 30px;
    }

    .game-note {
        font-size: 13px;
    }
}

@media (max-width: 600px) {
    .game-page {
        width: 100vw;
        max-width: none;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        padding: 0;
    }

    .game-card {
        width: 100vw;
        border-right-width: 0;
        border-left-width: 0;
        border-radius: 0;
    }

    #unity-container {
        width: 100vw;
        max-width: none;
    }

    #unity-canvas {
        width: 100vw !important;
        height: calc(100vw * .5859375) !important;
        min-height: 0;
    }

    .game-note {
        padding: 0 10px;
    }
}

body.game-mobile-fullscreen {
    margin: 0 !important;
    overflow: hidden !important;
    background: #000 !important;
}

body.game-mobile-fullscreen .game-page {
    position: fixed;
    z-index: 2147483647;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #000;
}

body.game-mobile-fullscreen .game-card,
body.game-mobile-fullscreen #unity-container {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #000;
}

body.game-mobile-fullscreen #unity-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

body.game-mobile-fullscreen #unity-canvas {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 0;
    max-width: none;
    object-fit: fill;
}

body.game-mobile-fullscreen #unity-footer,
body.game-mobile-fullscreen .game-note {
    display: none !important;
}

body.game-mobile-fullscreen #mobile-keyboard-footer-button {
    display: none !important;
}

#mobile-keyboard-button {
    display: none;
}

body.game-mobile-fullscreen #mobile-keyboard-button {
    position: fixed;
    z-index: 2147483647;
    bottom: env(safe-area-inset-bottom, 0px);
    left: env(safe-area-inset-left, 0px);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    background: rgba(26, 44, 56, .88);
    border: 1px solid rgba(180, 230, 255, .7);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}

body.game-mobile-fullscreen #mobile-keyboard-button:active {
    background: rgba(36, 153, 197, .95);
    transform: scale(.96);
}

@media (orientation: portrait) {
    body.game-mobile-fullscreen #unity-container::after {
        position: fixed;
        z-index: 2147483646;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 28px;
        color: #eaf9ff;
        font-size: 18px;
        font-weight: 700;
        line-height: 1.5;
        text-align: center;
        content: "Vui lòng xoay ngang điện thoại để chơi.";
        background: #07111b;
    }
}
