/* * This WebGL template is licensed to the purchaser only.
* Unauthorized copying, redistribution, modification, or use of this template or any of its components  in whole or in part  
* without a valid license is strictly prohibited and constitutes a violation of international copyright laws and licensing terms.
* This notice must remain intact in this file as a condition of use.
* Copyright  Devon Lively, 2025. All rights reserved. 
*/

@import url('styleVariables.css');

*,
*:before,
*:after {
    box-sizing: inherit;
}

@font-face {
    font-family: 'car-racing';
    src: url(../../GoboldLowplus.otf);
}

html {
    box-sizing: border-box;
}

html,
body {
    /* Using 100% instead of 100vh prevents bottom clipping from browser address bars */
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
    background-color: var(--PageSetup_PageBackgroundColor);
    /* iOS WebView keyboard fix: prevent scroll offset when keyboard shows/hides */
    position: fixed;
    top: 0;
    left: 0;
}

canvas {
    display: block;
}

#unity-canvas {
    width: 100%;
    height: 100%;
    background: var(--PageSetup_PageBackgroundColor);
}

#unity-container {
    position: relative;
    /* Prevent mobile overflow causing layout offset */
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--PageSetup_PageBackgroundColor);
}

/*//////////////////////////////////////////*/
/* Version Number Text */
/*//////////////////////////////////////////*/
#version-number-text {
    position: fixed;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--Footer_VersionTextColor);
    text-align: center;
    font-size: var(--Footer_VersionTextFontSize);
    z-index: 9993;
}

/*//////////////////////////////////////////*/
/* Loading Screen Cover */
/*//////////////////////////////////////////*/
#background-cover {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--backgroundURLPortrait);
    background-size: var(--PageSetup_ImageSizeStyle);
    background-repeat: var(--PageSetup_ImageRepeatStyle);
    background-position: center;
    z-index: 9990;
}

/*//////////////////////////////////////////*/
/* Landscape override */
/*//////////////////////////////////////////*/
@media (orientation: landscape) {
    #background-cover {
        background-image: var(--backgroundURLLandscape);
    }
}

#loading-cover {
    position: fixed;
    bottom: var(--LoadingScreen_ContainerYOffset);
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 9993;
}

#unity-logo {
    text-align: center;
}

#unity-logo img {
    max-width: var(--LoadingScreen_LogoImageMaxWidth);
}

/*//////////////////////////////////////////*/
/* Loading Bar */
/*//////////////////////////////////////////*/
#unity-loading-bar {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#unity-progress-bar-empty {
    width: var(--LoadingScreen_Frame_Width);
    height: var(--LoadingScreen_Frame_Height);
    margin: var(--LoadingScreen_Frame_LogoYOffset);
    border: var(--unity-progress-bar-emptyborder);
    padding: var(--LoadingScreen_Frame_Padding);
    position: relative;
    background-color: var(--LoadingScreen_Frame_BGColor);
    border-radius: var(--LoadingScreen_Frame_Radius);
    overflow: hidden;
}

@keyframes pulseColor {

    0%,
    100% {
        background-color: var(--pulse-start);
    }

    50% {
        background-color: var(--pulse-mid);
    }
}

.pulsing {
    animation: pulseColor 1.5s infinite ease-in-out;
}

#unity-progress-bar-full {
    height: 100%;
    width: 0%;
    background-color: #4caf50;
    transition: var(--unity-progress-bar-fulltransition);
    border-radius: var(--unity-progress-bar-fullborder-radius);
}

#progress-bar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
    color: black;
    font-size: var(--LoadingScreen_PercentValueFontSize);
    line-height: var(--LoadingScreen_TextLineHeight);
    pointer-events: none;
    z-index: 2;
}

/*//////////////////////////////////////////*/
/* Play Count */
/*//////////////////////////////////////////*/
#play-count {
    position: fixed;
    top: var(--PlayCounter_CornerOffsetY);
    right: var(--PlayCounter_CornerOffsetX);
    color: var(--PlayCounter_TextColor);
    font-size: (var--PlayCounter_TextFontSize);
    z-index: 9999;
}

/*//////////////////////////////////////////*/
/*minigames*/
/*//////////////////////////////////////////*/
#game-ready {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 4px;
    justify-content: center;
    font-size: 1rem;
    z-index: 9999;
}

#minigame-button {
    pointer-events: auto;
    margin-top: var(--LoadingScreen_SpaceBetweenLoadingBar);
    padding: 4px 8px;
    font-size: var(--LoadingScreen_MinigameButtonFontSize);
    background-color: var(--LoadingScreen_MinigameButtonColor);
    color: white;
    border: none;
    border-radius: var(--LoadingScreen_MinigameButtonRadius);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s;
}

#minigame-button:hover {
    background-color: #1565c0;
}

#minigame-button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2c80b4;
}

.iframe-container {
    position: relative;
    background: black;
    border: var(--iframe-containerborder);
    border-radius: var(--LoadingScreen_MinigameFrame_Radius);
    overflow: hidden;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    margin: 3% auto;

    width: 90vw;
    height: calc(90vw * 7 / 8);
    /* 8:7 ratio */
    max-height: 90vh;
}

.iframe-container iframe {
    width: 100%;
    height: 100%;
}

.close-iframe-button {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border: none;
    font-size: 20px;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10000;
}

/*//////////////////////////////////////////*/
/* Quote Table */
/*//////////////////////////////////////////*/
#quote-table {
    position: fixed;
    bottom: 5px;
    width: 85%;
    left: 50%;
    transform: translateX(-50%);
    color: var(--SharedTapAndLoadingSettings_QuoteTextColor);
    text-align: center;
    z-index: 9995;
    font-size: var(--Footer_QuoteTextFontSize);

    white-space: normal;
    /* allow wrapping */
    overflow-wrap: break-word;
    /* break long words if needed */
    word-wrap: break-word;
    /* fallback for older browsers */
}

#quote-table a {
    text-decoration: none;
    color: var(--SharedTapAndLoadingSettings_QuoteTextColor);
}

#quote-table a:hover {
    text-decoration: underline;
    color: var(--SharedTapAndLoadingSettings_QuoteTextColor);
}

/*//////////////////////////////////////////*/
/* Tap to Start Button */
/*//////////////////////////////////////////*/
#tap-to-start-button-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulse-scale 2s ease-in-out infinite;
}

@keyframes pulse-scale {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
}

#tap-to-start-button {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: none;
    color: white;
    font-size: var(--TapToStartScreen_TextFontSize);
    border: none;
    z-index: 9992;
    display: block;
    cursor: pointer;
}

/*//////////////////////////////////////////*/
/* Hamburger Menu */
/*//////////////////////////////////////////*/
#menu-options {
    flex-direction: column;
    gap: 5px;
    margin-top: 5px;
}

/* Hamburger Menu Buttons */
.menu-button {
    position: fixed;
    right: 10px;
    width: 38px;
    height: 38px;
    background-size: contain;
    z-index: 9989;
    border-radius: 4px;
}

#unity-menu-button {
    right: var(--HamburgerMenu_MainButtonOffsetX);
    bottom: var(--HamburgerMenu_MainButtonOffsetY);
    background: var(--unity-menu-button);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#unity-menu-button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2c80b4;
}

#unity-fullscreen-button {
    bottom: 10px;
    background: var(--unity-fullscreen-button);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#unity-fullscreen-button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2c80b4;
}

#close-menu-button {
    bottom: 10px;
    background: var(--close-menu-button);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#close-menu-button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2c80b4;
}

.menu-button.small-button {
    width: 28px;
    height: 28px;
    right: 10px;
    margin-bottom: 1px;
    border: none;
}

.menu-button.small-button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2c80b4;
}

/* Hamburger Menu Inner Buttons */
#rating-button.small-button {
    background: var(--rating-buttonsmall-button);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
}

.menu-button.small-button.custom-button {
    background: url('') no-repeat center;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
}

#menu-metrics-button.small-button {
    background: var(--menu-metrics-buttonsmall-button);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
}

#hm-installer-button.small-button {
    background: var(--hm-installer-buttonsmall-button);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
}

#menu-fs-button.small-button {
    background: var(--menu-fs-buttonsmall-button);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
}

#menu-fs-ios-button.small-button {
    background: var(--menu-fs-ios-buttonsmall-button);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
}

/*//////////////////////////////////////////*/
/* Rating Screen */
/*//////////////////////////////////////////*/
#ratingModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#rateTitleText {
    background-color: rgba(0, 0, 0, 0.35);
    border-radius: 5px;
}

.rating-selection-button {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    margin-left: 5px;
    margin-right: 5px;
    color: var(--RatingSystem_ButtonTextColor);
    background-color: var(--RatingSystem_ButtonColor);
    transition: color 0.2s;
}

.rating-selection-button.selected {
    color: grey;
}

#averageRating {
    padding-top: 5px;
}

#ratingWindow {
    background: #1eaed3;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.star {
    font-size: 40px;
    color: rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: color 0.2s;
}

.star.hover,
.star.selected {
    color: gold;
}

#loader-average-rating {
    position: fixed;
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: white;
    font-size: var(--RatingSystem_StarSizeInPixels);
    font-family: 'car-racing';
    text-shadow: 1px 1px 2px black;
    z-index: 9995;
}

#loading-cover-stars {
    margin-top: -10px;
}

.static-star {
    position: relative;
    display: inline-block;
    font-size: var(--RatingSystem_AverageTextSize);
    line-height: 1;
    color: #111;
    /* empty star color */
    width: 0.9em;
    /* keep a consistent glyph width */
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
}

.static-star::before {
    content: attr(data-icon);
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--fill, 0%);
    /* set by js */
    overflow: hidden;
    white-space: nowrap;
    color: gold;
    font-size: inherit;
    line-height: inherit;
    pointer-events: none;
}

.static-star,
.static-star::before {
    transition: width .18s linear, color .18s linear;
}

/*//////////////////////////////////////////*/
/* Metrics Overlay */
/*//////////////////////////////////////////*/
#metricsOverlayWrapper {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 9999;
    cursor: grab;
}

#metricsOverlayWrapper.dragging {
    cursor: grabbing;
}

#metricsOverlay {
    background: rgba(0, 0, 0, 0.85);
    color: var(--MetricsSettings_MetricsTextColor);
    font-family: 'car-racing';
    font-size: 13px;
    padding: 0;
    border-radius: 8px;
    width: 250px;
    box-shadow: var(--metricsOverlaybox-shadow);
    overflow: hidden;
}

.metrics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 8px 10px;
    border-bottom: var(--metrics-headerborder-bottom);
    font-weight: bold;
    font-size: 14px;
    user-select: none;
}

#metricsCloseBtn {
    background: none;
    border: none;
    color: #ff5c5c;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

#metricsCloseBtn:hover {
    color: #ff1f1f;
}

.metrics-body {
    padding: 10px;
}

/*//////////////////////////////////////////*/
/* Installer Menu */
/*//////////////////////////////////////////*/

/* Popup trigger style */
#install-modal-popup {
    position: fixed;
    top: var(--InstallMenu_ButtonOffsetY);
    left: var(--InstallMenu_ButtonOffsetX);
    background: var(--InstallMenu_PopupButtonColor);
    color: var(--InstallMenu_PopupButtonTextColor);
    padding: 3px 4px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'car-racing';
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 9995;
}

#install-modal-popup:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2c80b4;
}

#install-modal-popup div {
    background-color: rgba(0, 0, 0, 0.35);
    border-radius: 10px;
    padding: 3px 10px;
}

/* Modal background */
#install-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9996;
}

/* Modal content box */
.install-modal-content {
    position: relative;
    margin: 10% auto;
    width: 90%;
    max-width: 350px;
    color: var(--InstallMenu_TextColor);
    background: var(--InstallMenu_PanelColor);
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#install-modal-TitleText {
    background-color: rgba(0, 0, 0, 0.35);
    border-radius: 5px;
}

/* Close button */
#install-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 20px;
    cursor: pointer;
}

/* Buttons */
.install-modal-content button {
    padding: 5px 6px;
    margin-top: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: var(--InstallMenu_DeviceInstallButtonColor);
    color: var(--InstallMenu_DeviceInstallButtonTextColor);
    font-size: 1rem;
}

.install-modal-content button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2c80b4;
}

#install-store-icons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

#install-store-icons a {
    width: 50px;
    height: 50px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: inline-block;
}

#install-store-icons a:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2c80b4;
}

.popup-rotate {
    background-size: contain; /* <— FIX: luôn hiển thị đầy đủ ảnh */
    background-repeat: no-repeat;
    background-position: center;

    width: 80vw; /* popup luôn vừa màn hình */
    max-width: 400px;
    aspect-ratio: 413/247; /* giữ đúng tỷ lệ popup */

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    padding-bottom: 40px;
}
