/* JoJo ABC Patti Game CSS - FULLY FIXED VERSION */
/* Fixed all mobile layout, winner history, and UI positioning issues */

/* Winner History Section - FIXED: Show before betting */
.winner-history-section {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.history-title {
    color: #ecf0f1;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.winner-history {
    display: flex;
    justify-content: center;
    gap: 4px; /* Matches gap-1 in React component */
    flex-wrap: wrap;
}

/* History Items - Updated to match React component */
.history-item {
    width: 24px; /* Matches w-6 in React component */
    height: 24px; /* Matches h-6 in React component */
    border-radius: 50%;
    background: #34495e;
    color: #ecf0f1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    border: 2px solid #5d6d7e;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.history-item.winner-a {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-color: #c0392b;
    color: white;
    animation: winnerPulse 2s infinite;
}

.history-item.winner-b {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-color: #2980b9;
    color: white;
    animation: winnerPulse 2s infinite;
}

.history-item.winner-c {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    border-color: #27ae60;
    color: white;
    animation: winnerPulse 2s infinite;
}

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

/* Game Container */
.jojo-game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: #fff;
    font-family: 'Arial', sans-serif;
    position: relative;
    overflow: hidden;
}

.jojo-game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="stars" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="1" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23stars)"/></svg>');
    pointer-events: none;
    z-index: 0;
}

.jojo-game-container > * {
    position: relative;
    z-index: 1;
}

/* Header */
.jojo-header {
    text-align: center;
    margin-bottom: 30px;
}

.jojo-title {
    font-size: 2.5rem;
    background: linear-gradient(45deg, #FFD700, #FFA500, #FF6347);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0;
    animation: titleGlow 3s ease-in-out infinite alternate;
}

.jojo-subtitle {
    font-size: 1.2rem;
    color: #87CEEB;
    margin: 10px 0 0 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

@keyframes titleGlow {
    from { filter: brightness(1); }
    to { filter: brightness(1.2); }
}

/* FIXED: Timer, Your Coin, and Betting Phase in one line */
.jojo-timer-balance-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: nowrap;
}

.jojo-timer {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    padding: 15px 20px;
    border-radius: 15px;
    font-size: 1.6rem;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    border: 3px solid #c0392b;
    animation: timerPulse 1s ease-in-out infinite alternate;
    flex: 1;
    min-width: 120px;
}

/* FIXED: Your Coin - Positioned next to timer */
.user-balance {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    border-radius: 15px;
    padding: 15px 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
    flex: 1;
    min-width: 120px;
}

.balance-label {
    font-size: 0.9rem;
    color: #d5f4e6;
    margin-bottom: 5px;
    font-weight: bold;
}

.balance-amount {
    font-size: 1.3rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.jojo-phase {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex: 1;
    min-width: 120px;
}

.phase-icon {
    font-size: 1.3rem;
}

.phase-name {
    font-size: 1rem;
    font-weight: bold;
    color: #ecf0f1;
}

@keyframes timerPulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* FIXED: Game Boxes - Mobile optimized to fit in one line */
.jojo-game-boxes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px; /* Matches gap-2 in React component */
    margin-bottom: 30px;
}

.jojo-game-box {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-radius: 8px; /* Matches React component */
    padding: 12px; /* Matches p-3 in React component */
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 140px; /* Minimum height to accommodate content */
}

.jojo-game-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.jojo-game-box:hover::before {
    transform: translateX(100%);
}

.jojo-game-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
}

.jojo-game-box[data-box="A"] {
    border-color: #e74c3c;
}

.jojo-game-box[data-box="B"] {
    border-color: #3498db;
}

.jojo-game-box[data-box="C"] {
    border-color: #2ecc71;
}

.jojo-game-box.winner {
    border-color: #f1c40f;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    animation: winnerGlow 2s ease-in-out infinite alternate;
    transform: scale(1.05);
}

.jojo-game-box.loser {
    opacity: 0.6;
    filter: grayscale(50%);
}

@keyframes winnerGlow {
    from { box-shadow: 0 8px 25px rgba(241, 196, 15, 0.5); }
    to { box-shadow: 0 8px 35px rgba(241, 196, 15, 0.8); }
}

/* Box Label - Updated to match React component */
.box-label {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 32px; /* Matches w-8 in React component */
    height: 32px; /* Matches h-8 in React component */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    font-weight: bold;
    font-size: 14px;
    color: white;
}

.jojo-game-box[data-box="A"] .box-label {
    background: #10b981; /* green-500 */
}

.jojo-game-box[data-box="B"] .box-label {
    background: #3b82f6; /* blue-500 */
}

.jojo-game-box[data-box="C"] .box-label {
    background: #eab308; /* yellow-500 */
}

/* Playing Cards - Updated to match React component */
.playing-cards-container {
    margin: 15px 0;
}

.playing-cards {
    display: flex;
    justify-content: center;
    gap: 4px; /* Matches gap-1 in React component */
    margin-bottom: 10px;
}

.playing-card {
    width: 32px; /* Matches w-8 in React component */
    height: 48px; /* Matches h-12 in React component */
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: 1px solid #d1d5db; /* Matches border-gray-300 in React component */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.playing-card.card-hidden {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    color: #7f8c8d;
}

.playing-card.card-revealed {
    background: linear-gradient(135deg, #ecf0f1, #ffffff);
    transform: rotateY(0deg);
}

.playing-card.card-revealing {
    animation: cardFlip 0.6s ease-in-out;
}

@keyframes cardFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

.card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.card-rank {
    position: absolute;
    top: 0;
    left: 0;
    font-weight: bold;
    font-size: 10px;
}

.card-suit {
    font-size: 18px;
}

.card-red {
    color: #dc2626; /* red-600 */
}

.card-black {
    color: #1f2937; /* gray-800 */
}

/* Hand Rank */
.hand-rank {
    font-size: 0.9rem;
    font-weight: bold;
    color: #f1c40f;
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    min-height: 20px;
}

.box-info {
    font-size: 0.8rem;
    color: #bdc3c7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Winner Badge - Updated to match React component */
.winner-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #eab308; /* yellow-500 */
    color: black;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Bet Badge - Updated to match React component */
.bet-badge {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: #eab308; /* yellow-500 */
    color: black;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Betting Section */
.jojo-betting-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.betting-title {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    color: #f1c40f;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.betting-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.bet-option {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.bet-option:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.bet-option.placing-bet {
    animation: placingBet 0.8s ease-in-out;
}

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

.bet-label {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.bet-cards-display {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 8px 0;
}

.card-placeholder {
    width: 25px;
    height: 35px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #bdc3c7;
}

.box-total-bet {
    font-size: 0.85rem;
    color: #f1c40f;
    font-weight: bold;
    margin-top: 8px;
}

.bet-stats {
    font-size: 0.75rem;
    color: #95a5a6;
    margin-top: 5px;
}

/* Bet Amount Section */
.bet-amount-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.amount-selection-title {
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
    color: #ecf0f1;
}

.quick-bet-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.quick-bet-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 60px;
    font-size: 0.9rem;
}

.quick-bet-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.quick-bet-btn.selected {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    animation: selectedPulse 1s ease-in-out infinite alternate;
}

@keyframes selectedPulse {
    from { box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4); }
    to { box-shadow: 0 4px 20px rgba(231, 76, 60, 0.8); }
}

.selected-amount-display {
    text-align: center;
    font-size: 1.1rem;
    color: #f1c40f;
    font-weight: bold;
}

.selected-amount-value {
    color: #e74c3c;
    font-size: 1.2rem;
}

/* Phase Messages */
.phase-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: #f1c40f;
    padding: 20px 30px;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    z-index: 1000;
    text-align: center;
    border: 2px solid #f1c40f;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

@keyframes messageSlide {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* Loading Spinner */
.jojo-loading {
    text-align: center;
    padding: 40px;
}

.jojo-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid #f1c40f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* FIXED: Responsive Design for Mobile */
@media (max-width: 768px) {
    .jojo-game-container {
        padding: 15px;
    }
    
    .jojo-title {
        font-size: 1.8rem;
    }
    
    /* FIXED: Keep timer, coin, and phase in one line on mobile */
    .jojo-timer-balance-section {
        flex-direction: row;
        gap: 8px;
        flex-wrap: nowrap;
    }
    
    .jojo-timer,
    .user-balance,
    .jojo-phase {
        flex: 1;
        min-width: auto;
        padding: 10px 8px;
        font-size: 0.9rem;
    }
    
    .jojo-timer {
        font-size: 1.2rem;
    }
    
    .balance-amount {
        font-size: 1rem;
    }
    
    .balance-label {
        font-size: 0.8rem;
    }
    
    .phase-name {
        font-size: 0.9rem;
    }
    
    .phase-icon {
        font-size: 1.1rem;
    }
    
    /* FIXED: ABC boxes in one line on mobile */
    .jojo-game-boxes {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px; /* Matches gap-1 in React component */
    }
    
    .jojo-game-box {
        padding: 12px; /* Matches p-3 in React component */
        min-height: 120px;
    }
    
    .box-label {
        width: 32px; /* Matches w-8 in React component */
        height: 32px; /* Matches h-8 in React component */
        font-size: 14px;
    }
    
    .playing-cards {
        gap: 4px; /* Matches gap-1 in React component */
    }
    
    /* Adjust card size for medium screens */
    .playing-card {
        width: 48px; /* Matches sm:w-12 in React component */
        height: 64px; /* Matches sm:h-16 in React component */
    }
    
    .card-rank {
        font-size: 12px;
    }
    
    .card-suit {
        font-size: 24px;
    }
    
    .hand-rank {
        font-size: 0.75rem;
    }
    
    .box-info {
        font-size: 0.7rem;
    }
    
    /* Betting options in one line */
    .betting-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .bet-option {
        padding: 10px;
    }
    
    .bet-label {
        font-size: 1.1rem;
    }
    
    .card-placeholder {
        width: 20px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    .quick-bet-buttons {
        gap: 6px;
    }
    
    .quick-bet-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
        min-width: 45px;
    }
    
    .winner-history {
        gap: 4px; /* Matches gap-1 in React component */
    }
    
    .history-item {
        width: 24px; /* Matches w-6 in React component */
        height: 24px; /* Matches h-6 in React component */
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .jojo-game-container {
        padding: 10px;
    }
    
    .jojo-title {
        font-size: 1.5rem;
    }
    
    /* Keep elements in one line even on very small screens */
    .jojo-timer-balance-section {
        gap: 5px;
    }
    
    .jojo-timer {
        font-size: 1rem;
        padding: 8px 6px;
    }
    
    .user-balance,
    .jojo-phase {
        padding: 8px 6px;
    }
    
    .balance-amount {
        font-size: 0.9rem;
    }
    
    .balance-label {
        font-size: 0.7rem;
    }
    
    .phase-name {
        font-size: 0.8rem;
    }
    
    .jojo-game-boxes {
        gap: 1px; /* Matches gap-1 in React component */
    }
    
    .jojo-game-box {
        padding: 12px; /* Matches p-3 in React component */
        min-height: 100px;
    }
    
    .box-label {
        width: 32px; /* Matches w-8 in React component */
        height: 32px; /* Matches h-8 in React component */
        font-size: 14px;
    }
    
    /* Adjust card size for small screens */
    .playing-card {
        width: 32px; /* Matches w-8 in React component */
        height: 48px; /* Matches h-12 in React component */
    }
    
    .card-rank {
        font-size: 10px;
    }
    
    .card-suit {
        font-size: 18px;
    }
    
    .betting-options {
        gap: 6px;
    }
    
    .bet-option {
        padding: 8px;
    }
    
    .bet-label {
        font-size: 1rem;
    }
    
    .quick-bet-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-width: 40px;
    }
    
    .winner-history {
        gap: 1px; /* Matches gap-1 in React component */
    }
    
    .history-item {
        width: 24px; /* Matches w-6 in React component */
        height: 24px; /* Matches h-6 in React component */
        font-size: 12px;
    }
}