@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Khmer:wght@100..900&family=Rubik:ital,wght@0,300..900;1,300..900&display=swap');
*{
    font-family: "Noto Sans Khmer", sans-serif;
    font-optical-sizing: auto;
    font-weight:700;
}
body{
    background-image: url('../img/bg-square.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

html {
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

@media (orientation: portrait) {
    body {
        background-image: url('../img/bg-vertical.webp');
    }
}

@media (orientation: landscape) {
    body {
        background-image: url('../img/bg-horizontal.webp');
    }
}

.ad-section {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
}

.ad-section img {
    width: 100%;
    max-width: 500px;
    height: auto;
    display: block;
    object-fit: contain;
}

.game-container {
    padding-top: 25px;
    padding-bottom: 5px;
}

.game-section {
    margin-top: 25px;
}

.noscript-message {
    margin: 10px auto;
    max-width: 700px;
    padding: 10px 12px;
    border-radius: 6px;
    color: #fff;
    text-align: center;
    background-color: rgba(231, 76, 60, 0.95);
}

.language-switcher {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 0;
}

.language-link {
    min-width: 38px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    color: #fff;
    text-align: center;
    text-decoration: none;
    font-size: 0.8rem;
    line-height: 1.2;
    background-color: rgba(0, 0, 0, 0.35);
}

.language-link:hover,
.language-link.is-active {
    color: #fff;
    background-color: #e74c3c;
    border-color: #e74c3c;
}

.reel-container {
    background-color: #2c3e50;
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    perspective: 1000px;
    transform-style: preserve-3d;
    overflow: hidden;
    position: relative;
    aspect-ratio: 1/1;
    width: 100%;
}

.reel-img {
    width: 100%;
    height: 100%;
    border-radius: 5px;
    transition: transform 0.3s ease;
    backface-visibility: hidden;
    will-change: transform;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.slot-machine {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    padding: 8px;
}

#spinButton, #autoButton, #fullAutoButton {
    background-color: #e74c3c;
    border: none;
    transition: all 0.3s ease;
    will-change: transform;
}

#spinButton:hover, #autoButton:hover, #fullAutoButton:hover {
    background-color: #c0392b;
    transform: scale(1.05);
}

#result {
    min-height: 1.35em;
    font-weight: bold;
    margin-top: 8px;
    margin-bottom: 0;
    text-align: center;
    white-space: pre-line;
    line-height: 1.25;
}

.result-win {
    color: #ffd54f;
    text-shadow: 0 0 12px rgba(255, 213, 79, 0.9);
    animation: winPulse 0.6s ease-in-out 3;
}

.history-section, .seo-section {
    background-color: rgba(44, 62, 80, 0.92);
    border-radius: 10px;
    padding: 8px;
}

.score-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.score-box {
    background-color: rgba(44, 62, 80, 0.94);
    border-radius: 10px;
    padding: 8px;
    text-align: center;
}

.score-box.is-bank {
    background-color: rgba(17, 17, 17, 0.82);
    border: 1px solid rgba(255, 213, 79, 0.35);
}

.score-name {
    font-size: 0.85rem;
    line-height: 1.15;
}

.score-value {
    color: #ffd54f;
    font-size: 1.8rem;
    line-height: 1.1;
}

.score-bet {
    min-height: 1.25em;
    font-size: 0.78rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.history-title {
    text-align: center;
    font-size: 0.9rem;
    line-height: 1.2;
    margin-bottom: 4px;
}

#historyList {
    margin: 0;
    padding-left: 22px;
    font-size: 0.8rem;
    line-height: 1.25;
}

#historyList li {
    margin-top: 3px;
}

.history-win {
    color: #ffd54f;
}

.seo-section p {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.3;
    text-align: justify;
}

.seo-section p + p {
    margin-top: 5px;
}

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

.sliding {
    animation: slideDown 0.2s linear infinite;
    will-change: transform;
}

@keyframes slideDown {
    0% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(100%);
    }
}

.reel-container, .reel-img, #spinButton, .sliding {
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.slot-machine .row {
    margin: 0;
}

.slot-machine .col-4 {
    padding: 4px;
}

.available-images {
    background-color: #2c3e50;
    border-radius: 10px;
    padding: 8px;
}

.bet-title {
    text-align: center;
    font-size: 0.9rem;
    line-height: 1.15;
    margin-bottom: 5px;
    color: #ffd54f;
}

.image-preview {
    display: block;
    position: relative;
    aspect-ratio: 1/1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    margin-bottom: 3px;
}

.image-pick {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    color: #fff;
    background: transparent;
}

.image-pick.is-selected .image-preview {
    outline: 3px solid #ffd54f;
    box-shadow: 0 0 16px rgba(255, 213, 79, 0.9);
}

.server-pick {
    pointer-events: none;
    opacity: 0.86;
}

.server-label {
    display: none;
}

.bet-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 24px;
    height: 24px;
    padding: 2px 6px;
    border-radius: 999px;
    color: #111;
    background-color: #ffd54f;
    font-size: 0.8rem;
    line-height: 20px;
    text-align: center;
}

.bet-controls {
    display: grid;
    grid-template-columns: 32px 1fr 32px;
    gap: 4px;
    align-items: center;
    margin-top: 5px;
    padding: 0 2px;
}

.bet-control {
    height: 28px;
    border: 0;
    border-radius: 6px;
    color: #111;
    background-color: #ffd54f;
    line-height: 1;
}

.bet-control:disabled {
    opacity: 0.45;
}

.image-preview:hover {
    transform: scale(1.05);
}

.preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-title {
    text-align: center;
    font-weight: bold;
    color: #fff;
    padding: 2px;
    background-color: rgba(44, 62, 80, 0.9);
    border-radius: 4px;
    margin-top: 2px;
    font-size: 0.85rem;
    line-height: 1.1;
}

.sound-control {
    z-index: 1000;
}

.sound-control .btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sound-control .btn:hover {
    transform: scale(1.1);
}

.sound-control .bi {
    font-size: 1.2rem;
}

.winner-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    background-color: rgba(0, 0, 0, 0.45);
}

.winner-star {
    width: 690px;
    height: 690px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: #111;
    background: #ffd54f;
    clip-path: polygon(50% 0%,61% 34%,98% 35%,68% 56%,79% 91%,50% 70%,21% 91%,32% 56%,2% 35%,39% 34%);
    animation: starPop 1.2s ease-in-out infinite;
}

.winner-star div {
    width: 355px;
    font-size: 1.02rem;
    line-height: 1.15;
    overflow-wrap: anywhere;
    transform: translateY(18px);
}

.winner-star strong {
    width: 390px;
    font-size: 2.25rem;
    line-height: 1.05;
    overflow-wrap: anywhere;
    transform: translateY(8px);
}

@keyframes starPop {
    0%, 100% {
        transform: scale(1) rotate(-3deg);
    }
    50% {
        transform: scale(1.12) rotate(3deg);
    }
}

@media (max-width: 520px) {
    body {
        background-attachment: scroll;
        touch-action: pan-y;
    }

    .container {
        max-width: 100%;
        padding-left: 8px;
        padding-right: 8px;
    }

    .game-container {
        padding-top: 8px;
    }

    .game-section {
        margin-top: 12px;
    }

    .ad-section {
        padding: 0;
    }

    .ad-section img {
        max-width: 100%;
    }

    .language-switcher {
        gap: 5px;
    }

    .language-link {
        min-width: 42px;
        padding: 6px 8px;
        font-size: 0.78rem;
    }

    .available-images {
        padding: 6px;
        border-radius: 8px;
    }

    .available-images .col-2 {
        flex: 0 0 auto;
        width: 33.333333%;
        padding: 3px;
    }

    .bet-title {
        font-size: 0.95rem;
        margin-bottom: 4px;
    }

    .image-preview {
        margin-bottom: 2px;
    }

    .bet-badge {
        top: 3px;
        right: 3px;
        min-width: 22px;
        height: 22px;
        padding: 1px 5px;
        font-size: 0.78rem;
        line-height: 20px;
    }

    .bet-controls {
        grid-template-columns: 30px minmax(0, 1fr) 30px;
        gap: 3px;
        margin-top: 4px;
        padding: 0;
    }

    .bet-control {
        height: 28px;
        border-radius: 6px;
        font-size: 0.9rem;
    }

    .image-title {
        min-width: 0;
        padding: 0;
        font-size: 0.74rem;
        line-height: 28px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        background: transparent;
    }

    .slot-machine {
        padding: 6px;
        border-radius: 8px !important;
    }

    .slot-machine .col-4 {
        padding: 3px;
    }

    .reel-container {
        padding: 4px;
        border-radius: 8px;
    }

    .score-board {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
    }

    .score-box {
        min-width: 0;
        padding: 6px 3px;
        border-radius: 8px;
    }

    .score-box .score-bet {
        display: none;
    }

    .score-name {
        font-size: 0.7rem;
        line-height: 1.05;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .score-value {
        font-size: 1.45rem;
    }

    .score-bet {
        font-size: 0.76rem;
    }

    #spinButton, #autoButton, #fullAutoButton {
        width: calc((100% - 8px)/3);
        min-height: 44px;
        margin: 0 !important;
        padding-left: 0;
        padding-right: 0;
        font-size: 0.9rem;
    }

    #autoButton, #fullAutoButton {
        margin-left: 4px !important;
    }

    #fullAutoButton {
        font-size: 0;
    }

    #fullAutoButton::after {
        content: "Full";
        font-size: 0.9rem;
    }

    #fullAutoButton[aria-pressed="true"]::after {
        content: "Stop";
    }

    #result, .history-section {
        display: none;
    }

    .history-section, .seo-section {
        padding: 8px;
        border-radius: 8px;
    }

    .seo-section p {
        font-size: 0.8rem;
        line-height: 1.32;
    }

    .winner-star {
        position: absolute;
        left: 50%;
        top: 50%;
        width: min(570px, 112vw);
        height: min(570px, 112vw);
        animation: starPopMobile 1.2s ease-in-out infinite;
    }

    .winner-star div {
        width: min(305px, 58vw);
        font-size: 0.77rem;
    }

    .winner-star strong {
        width: min(355px, 70vw);
        font-size: 1.58rem;
    }
}

@keyframes starPopMobile {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.08);
    }
}

@media (min-width: 521px) and (max-width: 900px) {
    .container {
        max-width: 760px;
    }

    .available-images .col-2 {
        flex: 0 0 auto;
        width: 33.333333%;
        padding: 4px;
    }

    .bet-controls {
        grid-template-columns: 34px minmax(0, 1fr) 34px;
    }

    .image-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        background: transparent;
    }

    .score-box .score-bet, #result, .history-section {
        display: none;
    }

    .score-board {
        gap: 6px;
    }

    #spinButton, #autoButton, #fullAutoButton {
        width: calc((100% - 16px)/3);
        min-height: 46px;
        margin: 0 !important;
        padding-left: 0;
        padding-right: 0;
    }

    #autoButton, #fullAutoButton {
        margin-left: 8px !important;
    }

    #fullAutoButton {
        font-size: 0;
    }

    #fullAutoButton::after {
        content: "Full";
        font-size: 1rem;
    }

    #fullAutoButton[aria-pressed="true"]::after {
        content: "Stop";
    }

    .winner-overlay {
        place-items: center;
    }

    .winner-star {
        max-width: 98vw;
        max-height: 98vw;
    }
}

@media (min-width: 521px) and (max-width: 900px) and (orientation: landscape) {
    .container {
        max-width: 720px;
    }

    .game-section {
        margin-top: 16px;
    }

    .available-images .col-2 {
        width: 16.666667%;
        padding: 3px;
    }

    .bet-controls {
        grid-template-columns: 1fr 1fr;
        gap: 3px;
        padding: 0;
    }

    .bet-control {
        height: 28px;
    }

    .image-title {
        display: none;
    }
}
