/* RoboBlackjack - Mobile-First iPhone Optimized */
.roboblackjack-game {
    max-width: 100vw;
    margin: 0;
    padding: 5px;
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a472a 0%, #0d2818 100%);
    color: white;
    min-height: auto;
    overflow-x: hidden;
}

.roboblackjack-game * {
    box-sizing: border-box;
}

.blackjack-header {
    text-align: center;
    margin-bottom: 15px;
}

.blackjack-header h2 {
    margin: 0 0 5px 0;
    font-size: 1.5em;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 2px;
}

.game-info {
    color: #ddd;
    font-size: 0.8em;
    margin-bottom: 10px;
}

.game-info p {
    margin: 2px 0;
}

.learn-btn {
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.95em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
    margin-top: 8px;
}

.learn-btn:hover {
    background: linear-gradient(135deg, #7b1fa2 0%, #6a1b9a 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(156, 39, 176, 0.6);
}

/* Level & XP Display */
.level-display {
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    padding: 8px;
    margin-bottom: 10px;
    border: 2px solid #ffd700;
}

.level-info {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 1.2em;
}

.level-label {
    color: #aaa;
}

.level-value {
    color: #ffd700;
    font-weight: bold;
}

.xp-bar-container {
    position: relative;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    height: 25px;
    border: 2px solid #555;
    overflow: hidden;
}

.xp-bar {
    height: 100%;
    background: linear-gradient(90deg, #4caf50 0%, #81c784 100%);
    transition: width 0.5s ease;
    border-radius: 8px;
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9em;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Deck Selector */
.deck-selector {
    background: rgba(0,0,0,0.6);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 10px;
    text-align: center;
    border: 2px solid #4a90e2;
}

.deck-selector h3 {
    margin: 0 0 10px 0;
    color: #4a90e2;
    font-size: 1.1em;
}

.deck-options {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.deck-btn {
    padding: 10px 20px;
    font-size: 0.95em;
    font-weight: bold;
    border: 2px solid #4a90e2;
    border-radius: 6px;
    background: rgba(74, 144, 226, 0.2);
    color: #4a90e2;
    cursor: pointer;
    transition: all 0.3s;
}

.deck-btn:hover {
    background: rgba(74, 144, 226, 0.4);
    transform: translateY(-2px);
}

.deck-btn.active {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.6);
}

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

/* Chip Selector */
.chip-selector {
    background: rgba(0,0,0,0.6);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 10px;
    text-align: center;
    border: 2px solid #8B4513;
}

.chip-selector h3 {
    margin: 0 0 10px 0;
    color: #ffd700;
    font-size: 1.1em;
}

.chip-tray {
    display: flex;
    flex-direction: row;          /* force horizontal layout */
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;            /* keep chips on one line */
    overflow-x: auto;             /* allow horizontal scroll on small screens */
    -webkit-overflow-scrolling: touch;
    margin-bottom: 10px;
}

/* Table + Betting two-column layout */
.table-layout {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 10px;
}

.table-layout .chip-selector {
    flex: 0 0 35%;
    max-width: 200px;
}

.table-layout .blackjack-table {
    flex: 1 1 auto;
}

@media (max-width: 768px) {
    .table-layout {
        flex-direction: column;
    }
    
    .table-layout .chip-selector {
        max-width: 100%;
        flex: 0 0 auto;
    }
}

.chip {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    box-shadow: 
        0 4px 12px rgba(0,0,0,0.6), 
        inset 0 2px 4px rgba(255,255,255,0.3),
        inset 0 -2px 4px rgba(0,0,0,0.3);
}

.chip:hover {
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.8);
}

.chip.selected {
    transform: translateY(-6px) scale(1.15);
    box-shadow: 0 0 20px currentColor;
}

/* Chip Colors */
.chip-5 { 
    background: linear-gradient(135deg, #e53935 0%, #c62828 100%); 
    color: white; 
    border-color: #b71c1c;
}
.chip-10 { 
    background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%); 
    color: white; 
    border-color: #0d47a1;
}
.chip-25 { 
    background: linear-gradient(135deg, #43a047 0%, #2e7d32 100%); 
    color: white; 
    border-color: #1b5e20;
}
.chip-50 { 
    background: linear-gradient(135deg, #fb8c00 0%, #e65100 100%); 
    color: white; 
    border-color: #bf360c;
}
.chip-100 { 
    background: linear-gradient(135deg, #000 0%, #424242 100%); 
    color: #ffd700; 
    border-color: #ffd700;
}

.bet-amount {
    font-size: 1.2em;
    color: #ffd700;
    font-weight: bold;
}

/* Blackjack Table */
.blackjack-table {
    background: linear-gradient(135deg, #0a5f0a 0%, #085208 100%);
    border-radius: 20px;
    padding: 12px;
    margin-bottom: 10px;
    border: 4px solid #654321;
    box-shadow: 
        inset 0 0 30px rgba(0,0,0,0.5),
        0 10px 30px rgba(0,0,0,0.8);
}

.dealer-section, .player-section {
    margin-bottom: 12px;
}

.dealer-section h3, .player-section h3 {
    text-align: center;
    color: #ffd700;
    margin: 0 0 10px 0;
    font-size: 1.3em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

/* Multi-hand display for splits */
.player-hands-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.player-hand {
    padding: 10px;
    border-radius: 10px;
    background: rgba(0,0,0,0.3);
    border: 2px solid transparent;
}

.player-hand.active {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.player-hand.completed {
    opacity: 0.7;
}

.hand-label {
    text-align: center;
    color: #ffd700;
    font-size: 1em;
    margin-bottom: 5px;
    font-weight: bold;
}

.card-area {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 120px;
    align-items: center;
}

/* Playing Cards - SVG Images */
.card-container {
    display: inline-block;
    transition: transform 0.3s;
    cursor: pointer;
}

.card-container:hover {
    transform: translateY(-5px);
}

.card-svg {
    width: 80px;
    height: 112px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border-radius: 8px;
    display: block;
    background-color: #FFFFFF;
}

.card-svg.card-back {
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
}

/* Game Message */
.game-message {
    text-align: center;
    font-size: 1.3em;
    font-weight: bold;
    margin: 10px 0;
    min-height: 30px;
    padding: 8px;
    border-radius: 10px;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-message.win {
    color: #4caf50;
    background: rgba(76, 175, 80, 0.2);
}

.game-message.lose {
    color: #f44336;
    background: rgba(244, 67, 54, 0.2);
}

.game-message.push {
    color: #ff9800;
    background: rgba(255, 152, 0, 0.2);
}

.game-message.blackjack {
    color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
    animation: pulse 1s infinite;
}

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

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.bj-btn {
    padding: 8px 14px;
    font-size: 0.85em;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    color: white;
}

.deal-btn {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
}

.deal-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
    transform: translateY(-3px);
}

.hit-btn {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
}

.hit-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    transform: translateY(-3px);
}

.stand-btn {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
}

.stand-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #f57c00 0%, #e65100 100%);
    transform: translateY(-3px);
}

.double-btn, .split-btn {
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%);
}

.double-btn:hover:not(:disabled), .split-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #7b1fa2 0%, #6a1b9a 100%);
    transform: translateY(-3px);
}

.insurance-btn {
    background: linear-gradient(135deg, #00bcd4 0%, #0097a7 100%);
}

.insurance-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #0097a7 0%, #00838f 100%);
    transform: translateY(-3px);
}

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

/* Balance Display */
.balance-display {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 3px solid #ffd700;
}

.balance-display h3 {
    color: #ffd700;
    margin: 0 0 10px 0;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.balance-amount {
    color: #4caf50;
    font-weight: bold;
    font-size: 2em;
    text-shadow: 0 2px 10px rgba(76, 175, 80, 0.5);
}

/* Stats Display */
.stats-display {
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    border: 2px solid #555;
}

.stats-display h4 {
    color: #ffd700;
    margin: 0 0 10px 0;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
}

.stat-label {
    color: #aaa;
}

.stat-value {
    color: #ffd700;
    font-weight: bold;
}

/* Achievements */
.achievements-display {
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    border: 2px solid #ffd700;
}

.achievements-display h4 {
    color: #ffd700;
    margin: 0 0 10px 0;
    text-align: center;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.achievement {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    transition: all 0.3s;
    border: 2px solid #555;
}

.achievement.locked {
    opacity: 0.5;
    filter: grayscale(100%);
}

.achievement.unlocked {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
    animation: unlock 0.5s ease;
}

@keyframes unlock {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.achievement-icon {
    font-size: 2em;
    display: block;
    margin-bottom: 5px;
}

.achievement-name {
    font-size: 0.8em;
    color: white;
    display: block;
}

/* Tutorial Modal */
.tutorial-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    overflow-y: auto;
    animation: fadeIn 0.3s;
}

.tutorial-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tutorial-content {
    background: linear-gradient(135deg, #1a472a 0%, #0d2818 100%);
    border-radius: 15px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    border: 3px solid #ffd700;
    position: relative;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tutorial-header {
    background: linear-gradient(135deg, #0a5f0a 0%, #085208 100%);
    padding: 20px;
    border-bottom: 3px solid #ffd700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.tutorial-header h2 {
    margin: 0;
    color: #ffd700;
    font-size: 1.8em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.tutorial-close {
    background: transparent;
    border: none;
    color: #ffd700;
    font-size: 2.5em;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.tutorial-close:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: rotate(90deg);
}

.tutorial-body {
    padding: 20px;
    color: white;
}

.tutorial-section {
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border-left: 4px solid #ffd700;
}

.tutorial-section h3 {
    color: #ffd700;
    margin: 0 0 12px 0;
    font-size: 1.3em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.tutorial-section p {
    margin: 10px 0;
    line-height: 1.6;
    color: #ddd;
}

.tutorial-section ul {
    margin: 10px 0;
    padding-left: 25px;
    line-height: 1.8;
}

.tutorial-section li {
    margin: 8px 0;
    color: #ddd;
}

.tutorial-section li strong {
    color: #ffd700;
}

.tutorial-section em {
    color: #aaa;
    font-size: 0.95em;
    display: block;
    margin-top: 8px;
    padding-left: 10px;
    border-left: 2px solid #555;
}

.tutorial-footer {
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-top: 2px solid #ffd700;
    text-align: center;
    position: sticky;
    bottom: 0;
}

.tutorial-close-btn {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 30px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.tutorial-close-btn:hover {
    background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.6);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .roboblackjack-game {
        padding: 5px;
    }
    
    .blackjack-header h2 {
        font-size: 1.5em;
    }
    
    .chip {
        width: 50px;
        height: 50px;
        font-size: 0.9em;
    }
    
    .card-svg {
        width: 70px;
        height: 98px;
    }
    
    .bj-btn {
        padding: 8px 14px;
        font-size: 0.85em;
    }
    
    .balance-amount {
        font-size: 2em;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .tutorial-content {
        max-width: 95%;
        margin: 10px;
    }
    
    .tutorial-header h2 {
        font-size: 1.4em;
    }
    
    .tutorial-section {
        padding: 12px;
    }
    
    .tutorial-section h3 {
        font-size: 1.1em;
    }
    
    .tutorial-section ul {
        padding-left: 20px;
    }
}

