/* Mines - Stake style */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

html, body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #1e2c37;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 0 4vw;
}

/* Slot frame — обмеження ширини і висоти тут */
.slot-frame {
    position: relative;
    margin-top: 1vh;
    width: min(100%, 50vh);
    max-width: 100%;
    aspect-ratio: 1;
    max-height: 50vh;
    background-color: #14212d;
    padding: 3vw;
    border-radius: 3vw;
    margin-bottom: 4vw;
    overflow: hidden;
}

/* Main content — вище монеток (z-index 45) */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
    z-index: 50;
}

.logo {
    display: block;
    width: auto;
    max-width: 40vw;
    height: auto;
    max-height: 5vh;
    object-fit: contain;
    margin-bottom: 1vh;
    margin-top: 1vh;
}

/* Grid 3x3 — заповнює slot-frame, над монетками */
.grid-container {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2vw;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.grid-cell {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    background-color: #344452;
    contain: layout style paint;
    border-radius: 16%;
    cursor: pointer;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    transition: transform 0.12s ease, background-color 0.12s ease;
    box-shadow: 0 5px 0 #263642;
}

.grid-cell.cell-selected {
    transform: scale(1.06) translateZ(0);
    -webkit-transform: scale(1.06) translateZ(0);
    background-color: #4a5d70;
}

.grid-cell.opened {
    background-color: #0D1723;
    box-shadow: 0 5px 0 #0a1118;
}

.grid-cell .cell-result {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.grid-cell .cell-multiplier {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: clamp(3.5vh, 7vw, 10vw);
    font-weight: 800;
    color: #fff;
    opacity: 0;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    z-index: 3;
    will-change: transform;
}

.grid-cell .cell-multiplier.cell-multiplier-visible {
    animation: cellMultiplierIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s forwards;
}

@keyframes cellMultiplierIn {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
    60% {
        transform: translate(-50%, -50%) scale(1.25);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.grid-cell .cell-inner {
    width: 75%;
    height: 75%;
    object-fit: contain;
    transform: scale(0);
    opacity: 0;
    will-change: transform;
}

.grid-cell .cell-inner.cell-inner-visible {
    animation: cellInnerIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0s forwards;
}

@keyframes cellInnerIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    60% {
        transform: scale(1.25);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Нижній контент — max 50vh, все в vh для рівномірного поміщення */
.bottom-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.bottom-section > * {
    flex-shrink: 0;
}

/* Cashout button */
.btn-cashout {
    width: 100%;
    max-width: 90%;
    padding: 1vh 2.5vh;
    font-size: 2.5vh;
    font-weight: 700;
    color: #06080a;
    background: #69e344;
    border: none;
    border-radius: 1vh;
    cursor: pointer;
    margin-bottom: 2vh;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.25s ease;
}

.btn-cashout:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Bet section */
.bet-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 90%;
    margin-bottom: 0.8vh;
}

.bet-label {
    font-size: 1.8vh;
    color: #9ca3af;
}

.balance-label {
    font-size: 2vh;
    font-weight: 600;
}

/* Bet input — стиль з дизайну */
.bet-input-wrap {
    display: flex;
    align-items: stretch;
    background-color: #242C36;
    border: 1px solid #3C4B5E;
    border-radius: 1.2vh;
    min-height: 7vh;
    margin-bottom: 1.5vh;
    width: 100%;
    max-width: 90%;
    overflow: hidden;
}

.bet-value-cell {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 1vh 2.5vh;
    min-width: 0;
    background: #14212d;
}

.bet-input {
    width: 100%;
    min-width: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 3vh;
    font-weight: 600;
}

.bet-input:focus {
    outline: none;
}

.bet-divider-vert {
    width: 1px;
    background-color: #3C4B5E;
    flex-shrink: 0;
}

.bet-actions .bet-divider-vert {
    background-color: #1e2c37;
}

.bet-bitcoin-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2vh;
    background: #14212d;
}

.bet-bitcoin {
    width: 3.5vh;
    height: 3.5vh;
    min-width: 22px;
    min-height: 22px;
    object-fit: contain;
}

.bet-actions {
    display: flex;
    align-items: stretch;
}

.btn-bet {
    padding: 1.5vh 2vh;
    font-size: 2.2vh;
    font-weight: 600;
    color: #fff;
    background: #344452;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-bet:last-child {
    border-radius: 0 1.2vh 1.2vh 0;
}

/* Info fields: Mines+Crystals в 1 рядку, Total Win окремо */
.info-fields {
    display: flex;
    flex-direction: column;
    gap: 1.5vh;
    width: 100%;
    max-width: 90%;
}

.info-row-mc {
    display: flex;
    gap: 1.5vh;
}

.info-row-mc .info-field {
    flex: 1;
}

.info-field {
    display: flex;
    flex-direction: column;
    gap: 0.6vh;
}

.info-field .info-label {
    font-size: 1.5vh;
    color: #9ca3af;
}

.info-input {
    background-color: #14212d;
    border: 1px solid #3C4B5E;
    border-radius: 0.8vh;
    padding: 1.2vh 2vh;
    min-height: 5.5vh;
    display: flex;
    align-items: center;
}

.info-input-win {
    position: relative;
    padding-right: 8vh;
}

.info-field .info-value {
    font-size: 2vh;
    font-weight: 600;
    color: #fff;
}

#total-win-value {
    display: inline-block;
}

#total-win-value.total-win-bump {
    animation: totalWinBump 0.35s ease-out;
}

@keyframes totalWinBump {
    0% { transform: scale(1); }
    40% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.info-btc-wrap {
    position: absolute;
    right: 1.5vh;
    top: 50%;
    transform: translateY(-50%);
    background: #14212d;
    border-radius: 0.6vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-btc {
    width: 2.5vh;
    height: 2.5vh;
    min-width: 18px;
    min-height: 18px;
    object-fit: contain;
}

/* Bet toast popup */
.bet-toast {
    position: fixed;
    bottom: 6vw;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    padding: 1.5vw 3vw;
    font-size: 3vw;
    font-weight: 600;
    background: #2B343D;
    color: #fff;
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 50;
}

.bet-toast.visible {
    opacity: 1;
    visibility: visible;
    animation: betToastIn 0.3s ease-out forwards;
}

@keyframes betToastIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Landscape */
@media (orientation: landscape) {
    #app {
        padding: 0 0 2vh;
    }

    .slot-frame {
        padding: 2vh;
        margin-bottom: 2vh;
    }

    .grid-container {
        gap: 1.5vh;
    }

    .btn-cashout {
        padding: 2vh 3vh;
        font-size: 2.5vh;
        margin-bottom: 2vh;
    }

    .bet-row .bet-label {
        font-size: 2vh;
    }

    .bet-input-wrap {
        min-height: 48px;
        margin-bottom: 1.5vh;
    }

    .bet-value-cell {
        padding: 2vh 2.5vh;
    }

    .bet-input {
        font-size: 3.5vh;
    }

    .bet-bitcoin-cell {
        padding: 0 2vh;
    }

    .bet-bitcoin {
        width: 4vh;
        height: 4vh;
        min-width: 24px;
        min-height: 24px;
    }

    .btn-bet {
        padding: 1.5vh 2.5vh;
        font-size: 2.5vh;
    }

    .balance-label {
        font-size: 2.2vh;
    }

    .info-field .info-label {
        font-size: 2vh;
    }

    .info-input {
        min-height: 38px;
        padding: 1.5vh 2vh;
    }

    .info-field .info-value {
        font-size: 2.5vh;
    }

    .info-btc-wrap {
        padding: 0.8vh;
    }

    .info-btc {
        width: 3vh;
        height: 3vh;
        min-width: 16px;
        min-height: 16px;
    }

    .bet-toast {
        bottom: 4vh;
        padding: 1vh 2.5vh;
        font-size: 2vh;
    }
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    contain: layout style paint;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

#win-overlay {
    opacity: 0;
    transition: opacity 0.45s ease;
}

#win-overlay.overlay-visible {
    opacity: 1;
}

#win-overlay.win-overlay-fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

#bonus-overlay {
    opacity: 0;
    transition: opacity 0.6s ease;
}

#bonus-overlay.bonus-overlay-visible {
    opacity: 1;
}

.tutorial-toast {
    position: fixed;
    bottom: 35vh;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    padding: 3vw 6vw;
    font-size: 4.5vw;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    background: #2B343D;
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    z-index: 50;
    pointer-events: none;
    max-width: 90%;
}

.tutorial-toast.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    animation: tutorialToastIn 0.4s ease-out forwards;
}

.tutorial-toast.visible.tutorial-fade-out {
    animation: tutorialToastOut 0.35s ease-in forwards;
}

@keyframes tutorialToastIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes tutorialToastOut {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(8px);
    }
}

@media (orientation: landscape) {
    .tutorial-toast {
        bottom: 32vh;
        font-size: 3vh;
        padding: 2.5vh 5vh;
    }
}

.win-confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
}

.win-confetti-phase1 {
    z-index: 1;
}

.win-confetti.win-confetti-visible {
    opacity: 1;
    transition: none;
}

#win-overlay .win-content {
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.35s ease 0.1s, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s;
}

#win-overlay .win-content.win-content-visible {
    opacity: 1;
    transform: scale(1);
}

#win-overlay .win-content.win-content-visible .win-multiplier {
    animation: winLineFromTop 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#win-overlay .win-content.win-content-visible .win-amount {
    animation: winLineFromBottom 1.4s cubic-bezier(0.22, 1, 0.36, 1) 0.25s forwards;
}

#win-overlay .win-content.win-content-visible .win-multiplier.win-text-settled,
#win-overlay .win-content.win-content-visible .win-amount.win-text-settled {
    animation: winTextPulse 1.2s ease-in-out infinite;
}

@keyframes winLineFromTop {
    0% {
        opacity: 0;
        transform: translateY(-180%);
    }
    55% {
        opacity: 1;
        transform: translateY(8%) scaleY(0.88);
    }
    70% {
        transform: translateY(-3%) scaleY(1.06);
    }
    85% {
        transform: translateY(2%) scaleY(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scaleY(1);
    }
}

@keyframes winLineFromBottom {
    0% {
        opacity: 0;
        transform: translateY(180%);
    }
    55% {
        opacity: 1;
        transform: translateY(-8%) scaleY(0.88);
    }
    70% {
        transform: translateY(3%) scaleY(1.06);
    }
    85% {
        transform: translateY(-2%) scaleY(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scaleY(1);
    }
}

@keyframes winTextPulse {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(0) scale(1.06);
    }
}

.coins-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    contain: layout style paint;
}

.falling-coin {
    position: absolute;
    top: -10%;
    width: 4vw;
    height: 4vw;
    min-width: 24px;
    min-height: 24px;
    object-fit: contain;
    animation: coinFall linear forwards;
}

@keyframes coinFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0.9;
    }
}

#bonus-overlay .confetti-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 45vh;
    min-height: 120px;
    object-fit: cover;
    object-position: top;
    pointer-events: none;
    z-index: 1;
}

@keyframes winContentIn {
    0% {
        opacity: 0;
        transform: scale(0.85) translateZ(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateZ(0);
    }
}

.win-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}


.win-multiplier {
    font-size: 16vw;
    font-weight: 800;
    color: #00d26a;
    margin-bottom: 2vw;
    opacity: 0;
}

.win-amount {
    font-size: 8vw;
    font-weight: 600;
    color: #fff;
    opacity: 0;
}

/* Bonus overlay — confetti в фінальній сцені */
#bonus-overlay .confetti-img {
    max-height: 50vh;
}

.bonus-text {
    position: relative;
    z-index: 2;
    font-size: 10vw;
    font-weight: 600;
    text-align: center;
    margin-bottom: 5vw;
    padding: 0 5vw;
    line-height: 1.3;
}

@keyframes pulseBtn {
    0%, 100% { transform: scale(1) translateZ(0); }
    50% { transform: scale(1.05) translateZ(0); }
}

.btn-claim {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2vw;
    padding: 6.5vw 10vw;
    font-size: 7vw;
    font-weight: 700;
    color: #fff;
    background: #00d26a;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 4vw;
    -webkit-tap-highlight-color: transparent;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    animation: pulseBtn 1.5s ease-in-out infinite;
}

.btn-claim-btc {
    width: 6vw;
    height: 6vw;
    min-width: 28px;
    min-height: 28px;
    object-fit: contain;
}

@media (orientation: landscape) {
    .win-multiplier {
        font-size: 14vh;
        margin-bottom: 1.5vh;
    }

    .win-amount {
        font-size: 7vh;
    }

    .bonus-text {
        font-size: 4.5vh;
        margin-bottom: 3vh;
    }

    .btn-claim {
        padding: 2.5vh 6vh;
        font-size: 2.5vh;
        gap: 1.5vh;
        margin-bottom: 2.5vh;
    }

    .btn-claim-btc {
        width: 5vh;
        height: 5vh;
        min-width: 24px;
        min-height: 24px;
    }
}
