@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
    --stake-bg-dark: #0f212e;
    --stake-bg-light: #213743;
    --stake-bg-input: #0f212e;
    --stake-border: #2f4553;
    --stake-border-hover: #557086;
    --stake-text-muted: #b1bad3;
    --stake-text-white: #ffffff;
    --stake-green: #00e701;
    --stake-green-hover: #1fff20;
    --stake-orange: #f7931a;
    --stake-red: #ff0000;
}

.flippo-wrapper, .flippo-wrapper * {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

.flippo-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--stake-bg-dark);
    border-radius: 8px;
    max-width: 900px;
    margin: 20px auto;
    overflow: hidden;
}

@media (min-width: 768px) {
    .flippo-wrapper {
        flex-direction: row;
        height: 520px;
    }
    .stake-controls {
        width: 300px;
        background: var(--stake-bg-light);
        flex-shrink: 0;
        border-right: 2px solid var(--stake-bg-dark);
    }
    .stake-game-area {
        flex: 1;
        display: flex;
        flex-direction: column;
        background: var(--stake-bg-dark);
        position: relative; /* CRITICAL FOR CENTERING */
        overflow: hidden;
    }
}

/* --- SIDEBAR CONTROLS --- */
.stake-controls {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--stake-text-muted);
    display: flex;
    justify-content: space-between;
}

.stake-input-wrapper {
    display: flex;
    background: var(--stake-bg-input);
    border: 2px solid var(--stake-border);
    border-radius: 4px;
    height: 38px;
    align-items: center;
    transition: border-color 0.2s;
}

.stake-input-wrapper:focus-within {
    border-color: var(--stake-border-hover);
}

.stake-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--stake-text-white);
    font-size: 14px;
    font-weight: 700;
    padding: 0 10px;
    outline: none;
    width: 100%;
}

.stake-input-append {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 4px;
}

.stake-input-append button {
    background: var(--stake-border);
    border: none;
    color: var(--stake-text-white);
    padding: 0 10px;
    height: 26px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.stake-input-append button:hover { background: var(--stake-border-hover); }

/* Pick a Side Buttons (Inside Sidebar) */
.coin-selectors {
    display: flex;
    gap: 8px;
    width: 100%;
}

.select-btn {
    flex: 1;
    background: var(--stake-bg-input);
    border: 2px solid var(--stake-border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.select-btn:hover:not(:disabled) {
    border-color: var(--stake-border-hover);
    background: rgba(255,255,255,0.02);
}

.select-btn.active {
    border-color: var(--stake-border-hover);
    background: var(--stake-border);
}

.select-btn img {
    width: 36px;
    height: 36px;
}

.select-btn span.coin-name {
    color: var(--stake-text-white);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
}

/* Big Action Buttons */
.stake-bet-btn {
    background: var(--stake-green);
    color: #000;
    border: none;
    padding: 16px;
    margin-top: auto;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-transform: uppercase;
}
.stake-bet-btn:hover:not(:disabled) { background: var(--stake-green-hover); }
.stake-bet-btn:active:not(:disabled) { transform: scale(0.98); }
.stake-bet-btn:disabled { 
    background: var(--stake-border); 
    color: var(--stake-text-muted); 
    cursor: not-allowed; 
}


/* --- GAME AREA & COIN RENDERING --- */
.stake-game-area {
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Header history bar */
.history-container {
    width: 100%;
    background: rgba(0,0,0,0.2);
    padding: 12px 20px;
    border-bottom: 1px solid var(--stake-border);
    position: relative;
    z-index: 10;
}

.history-label {
    font-size: 10px;
    font-weight: 800;
    color: var(--stake-text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    display: block;
}

.history-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    justify-content: flex-start;
    overflow: hidden;
    position: relative;
    /* MASK THE RIGHT SIDE FOR SMOOTH EXIT */
    mask-image: linear-gradient(to right, black 80%, transparent 100%);
}

.history-dot {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: var(--stake-bg-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.history-dot img {
    width: 20px;
    height: 20px;
}
.history-dot.win { border: 2px solid var(--stake-green); }
.history-dot.loss { border: 2px solid var(--stake-red); }

/* Center Engine */
.coin-stage-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
}

/* The Live Multiplier */
.current-multiplier {
    font-size: 44px;
    font-weight: 900;
    color: var(--stake-green);
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    visibility: hidden;
    z-index: 5;
    text-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
.current-multiplier.active { 
    opacity: 1; 
    visibility: visible;
}
.current-multiplier.loss { 
    color: var(--stake-text-muted); 
}

/* Simple 3D Coin - SIZE BUMPED + CENTERED */
.coin-stage {
    width: 260px;
    height: 260px;
    position: relative;
    perspective: 1200px; 
}

.virtual-coin {
    width: 100%;
    height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    border-radius: 50%;
    transform: rotateY(0deg); 
}

/* CLEAN KEYFRAMES */
.virtual-coin.spin-bitcoin {
    animation: flipToBitcoin 1.4s cubic-bezier(0.1, 0.7, 0.1, 1) forwards;
}
.virtual-coin.spin-solana {
    animation: flipToSolana 1.4s cubic-bezier(0.1, 0.7, 0.1, 1) forwards;
}

@keyframes flipToBitcoin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(1800deg); }
}

@keyframes flipToSolana {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(1980deg); }
}

.coin-side {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.6); 
}

.coin-front {
    background-image: url('../assets/Flippo/BitcoinToken.png');
    transform: rotateY(0deg) translateZ(2px);
}
.coin-back {
    background-image: url('../assets/Flippo/SolanaToken.png');
    transform: rotateY(180deg) translateZ(2px);
}

.coin-edge {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #000;
    backface-visibility: hidden;
    transform: rotateY(180deg) translateZ(-4px);
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
}

/* --- WIN POPUP --- */
.flippo-win-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    background: linear-gradient(135deg, rgba(0, 231, 1, 0.98), rgba(0, 180, 0, 1));
    border: 2px solid #1fff20;
    border-radius: 8px;
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(0, 231, 1, 0.6);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.flippo-win-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.flippo-win-mult {
    font-size: 24px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 2px;
}

.flippo-win-payout {
    font-size: 14px;
    font-weight: 700;
    color: #e0ffd1;
    background: rgba(0,0,0,0.2);
    padding: 3px 10px;
    border-radius: 12px;
}

/* --- MOBILE RESPONSIVENESS & THEME POLISH --- */
@media (max-width: 767px) {
    .flippo-wrapper {
        flex-direction: column;
        height: auto; 
        margin: 10px;
        max-width: 100%;
        gap: 0;
    }
    
    .stake-controls {
        width: 100% !important;
        order: 2; /* Put settings AFTER the game stage */
        padding: 15px;
        gap: 12px;
        display: flex;
        flex-direction: column;
    }

    .stake-game-area {
        order: 1; /* Main coin stage on top */
        min-height: 320px;
    }

    /* THE FLIP BUTTON: JUMP TO TOP ON MOBILE */
    .stake-bet-btn {
        margin-top: 0 !important;
        margin-bottom: 5px;
        order: -1; 
        font-size: 16px;
        padding: 18px;
    }

    .coin-stage {
        width: 180px;
        height: 180px;
    }

    .current-multiplier {
        font-size: 32px;
        top: 15px;
    }

    .history-container {
        padding: 8px 12px;
        width: 100% !important; 
    }

    .history-strip {
        height: 28px;
    }

    .history-dot {
        width: 24px;
        height: 24px;
    }
}

