/* Four Card Keno Simulator Styles - Tablet Optimized */
#four-card-keno-simulator {
    font-family: Arial, sans-serif;
    background: #000;
    color: #fff;
    padding: 20px;
    border-radius: 10px;
    max-width: 1400px;
    margin: 0 auto;
    /* Prevent zoom and selection */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Session Analytics Panel */
.session-panel {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    border: 2px solid #333;
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.session-header h3 {
    margin: 0;
    color: #00ff88;
    font-size: 18px;
}

.toggle-btn {
    background: #444;
    color: #fff;
    border: none;
    padding: 5px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
    touch-action: manipulation;
    min-height: 44px;
}

.toggle-btn.small {
    padding: 3px 10px;
    font-size: 10px;
    min-height: 32px;
}

.toggle-btn:hover {
    background: #666;
}

.mobile-only {
    display: none;
}

.session-setup {
    border-top: 1px solid #333;
    padding-top: 15px;
}

.setup-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.setup-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.setup-item label {
    font-size: 12px;
    color: #ccc;
    font-weight: bold;
}

.setup-item input {
    background: #333;
    border: 1px solid #555;
    color: #fff;
    padding: 8px;
    border-radius: 3px;
    font-size: 14px;
    touch-action: manipulation;
}

.setup-item input:focus {
    outline: none;
    border-color: #00ff88;
}

.session-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-btn {
    background: #0066cc;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    transition: all 0.3s ease;
    touch-action: manipulation;
    min-height: 44px;
}

.action-btn:hover {
    transform: translateY(-2px);
}

.action-btn.start {
    background: #00aa00;
}

.action-btn.start:hover {
    background: #00cc00;
}

.action-btn.end {
    background: #cc6600;
}

.action-btn.end:hover {
    background: #ff8800;
}

.action-btn.reset {
    background: #cc0000;
}

.action-btn.reset:hover {
    background: #ff0000;
}

.action-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

/* Session Stats */
.session-stats {
    border-top: 1px solid #333;
    padding-top: 15px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.stat-item {
    background: #333;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

.stat-label {
    font-size: 10px;
    color: #ccc;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 16px;
    font-weight: bold;
    color: #00ff88;
}

.stat-value.negative {
    color: #ff4444;
}

.stat-value.positive {
    color: #44ff44;
}

/* Card Performance Section */
.card-performance-section {
    margin-top: 15px;
    border-top: 1px solid #333;
    padding-top: 15px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12px;
    color: #ccc;
    font-weight: bold;
}

.card-performance {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.card-perf {
    background: #333;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

.card-perf[data-card="A"] {
    border-left: 4px solid #00aa00;
}

.card-perf[data-card="B"] {
    border-left: 4px solid #00ccff;
}

.card-perf[data-card="C"] {
    border-left: 4px solid #cc6600;
}

.card-perf[data-card="D"] {
    border-left: 4px solid #cc0066;
}

.perf-header {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 12px;
}

.perf-stats {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    color: #ccc;
}

/* Main Game Styles */
.keno-container {
    display: flex;
    gap: 20px;
}

/* Left Panel Styles */
.card-info-panel {
    width: 300px;
    background: #1a1a1a;
    border-radius: 8px;
    padding: 15px;
    height: fit-content;
}

.card-info-header {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.game-title {
    font-size: 18px;
    font-weight: bold;
    color: #00ff00;
    margin-bottom: 10px;
}

.card-info {
    background: #333;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.card-info.big-win {
    background: #ffff00 !important;
    color: #000 !important;
    animation: pulse 1s infinite;
}

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

.card-label {
    color: #fff;
    font-weight: bold;
    margin-bottom: 5px;
    padding: 5px;
    text-align: center;
    border-radius: 3px;
}

.card-info.big-win .card-label {
    background: #000 !important;
    color: #ffff00 !important;
}

.card-stats {
    font-size: 12px;
    line-height: 1.4;
}

.card-spots {
    margin-top: 5px;
    font-size: 10px;
    min-height: 20px;
}

.card-spots .hit-number {
    background: #cccc44;
    color: #000;
    padding: 1px 3px;
    border-radius: 2px;
    margin: 0 1px;
}

/* Card Colors */
.card-info[data-card="A"] .card-label { background: #00aa00; }
.card-info[data-card="B"] .card-label { background: #00ccff; color: #000; }
.card-info[data-card="C"] .card-label { background: #cc6600; }
.card-info[data-card="D"] .card-label { background: #cc0066; }

/* Main Game Area */
.game-area {
    flex: 1;
}

.card-tabs {
    display: flex;
    margin-bottom: 15px;
    gap: 5px;
}

.card-tab {
    background: #666;
    color: #fff;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 5px 5px 0 0;
    transition: background 0.3s;
    touch-action: manipulation;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.card-tab[data-card="A"].active { background: #00aa00; }
.card-tab[data-card="B"].active { background: #00ccff; color: #000; }
.card-tab[data-card="C"].active { background: #cc6600; }
.card-tab[data-card="D"].active { background: #cc0066; }
.card-tab[data-card="ALL"].active { background: #666; }

.card-tab:hover {
    background: #888;
}

.card-tab.active:hover {
    filter: brightness(1.2);
}

/* Number Grid */
.number-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
    margin-bottom: 20px;
    background: #333;
    padding: 10px;
    border-radius: 8px;
    height: 520px;
    align-content: start;
}

.number-button {
    width: 100%;
    height: 58px;
    background: #0066cc;
    color: #fff;
    border: 1px solid #004499;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.number-button:hover {
    background: #0088ff;
    transform: scale(1.1);
}

.number-button.selected-A {
    background: #00aa00;
    border-color: #008800;
    color: #fff;
}

.number-button.selected-B {
    background: #00ccff;
    border-color: #00aadd;
    color: #000;
}

.number-button.selected-C {
    background: #cc6600;
    border-color: #aa5500;
    color: #fff;
}

.number-button.selected-D {
    background: #cc0066;
    border-color: #aa0055;
    color: #fff;
}

.number-button.multiple-cards {
    background: #ffaa00;
    border-color: #ff8800;
    color: #000;
    position: relative;
}

.number-button.multiple-cards::after {
    content: "*";
    position: absolute;
    top: -2px;
    right: 2px;
    font-size: 16px;
    font-weight: bold;
    color: #000;
}

/* Prevent number button scaling during animation to avoid layout shift */
.number-button.drawn {
    background: #ff0000;
    border-color: #cc0000;
    color: #fff;
    animation: drawRevealNoScale 0.5s ease;
}

.number-button.hit {
    background: #cccc44;
    border-color: #aaaa22;
    color: #000;
    animation: hitFlash 0.8s ease;
}

@keyframes drawRevealNoScale {
    0% { background: #0066cc; }
    50% { background: #ffff00; }
    100% { background: #ff0000; }
}

@keyframes hitFlash {
    0% { background: #ff0000; }
    50% { background: #ffff00; }
    100% { background: #cccc44; }
}

/* Game Status Bar - FORCE horizontal on all devices */
.game-status-bar {
    background: #1a1a1a;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 20px;
    flex-wrap: nowrap !important;
}

.game-status-bar > * {
    flex-shrink: 0 !important;
}

.credits-display {
    font-size: 18px;
    color: #ffff00;
    font-weight: bold;
    white-space: nowrap;
}

#total-bet, #total-win {
    font-size: 16px;
    color: #ffff00;
    font-weight: bold;
    white-space: nowrap;
}

/* Control Panel - FORCE horizontal on all devices */
.control-panel {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 8px;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 15px;
    flex-wrap: nowrap !important;
}

.bet-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bet-controls button {
    background: #666;
    color: #fff;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    touch-action: manipulation;
    min-height: 44px;
    min-width: 44px;
}

.bet-controls button:hover {
    background: #888;
}

#current-bet {
    font-size: 18px;
    font-weight: bold;
    color: #ffff00;
    min-width: 30px;
    text-align: center;
}

.game-controls {
    display: flex;
    gap: 10px;
}

.game-controls button, .game-controls select {
    background: #0066cc;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    touch-action: manipulation;
    min-height: 44px;
}

.game-controls button:hover, .game-controls select:hover {
    background: #0088ff;
    transform: translateY(-2px);
}

#speed-selector {
    font-size: 12px;
    padding: 10px 8px;
}

#speed-selector:hover {
    transform: none;
}

#draw-button {
    background: #ff6600 !important;
    font-size: 16px;
    padding: 12px 20px !important;
    min-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#draw-button:hover {
    background: #ff8800 !important;
}

#draw-button:disabled {
    background: #666 !important;
    cursor: not-allowed;
    transform: none !important;
}

/* Saved Configurations Section */
.saved-configs-panel {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    border: 2px solid #333;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.config-header h3 {
    margin: 0;
    color: #00ccff;
    font-size: 16px;
}

.config-list {
    border-top: 1px solid #333;
    padding-top: 15px;
}

.no-configs, .no-history {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 20px;
}

.config-items {
    display: grid;
    gap: 10px;
}

.config-item {
    background: #333;
    padding: 15px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.config-info {
    flex: 1;
}

.config-name {
    font-weight: bold;
    color: #00ccff;
    margin-bottom: 5px;
}

.config-details {
    font-size: 12px;
    color: #ccc;
    display: flex;
    gap: 15px;
}

.config-actions {
    display: flex;
    gap: 10px;
}

.config-actions button {
    background: #0066cc;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.3s;
    touch-action: manipulation;
    min-height: 44px;
}

.config-actions .load-btn {
    background: #00aa00;
}

.config-actions .load-btn:hover {
    background: #00cc00;
}

.config-actions .delete-btn {
    background: #cc0000;
}

.config-actions .delete-btn:hover {
    background: #ff0000;
}

/* Session History Section */
.history-panel {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 15px;
    border: 2px solid #333;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-header h3 {
    margin: 0;
    color: #ffaa00;
    font-size: 16px;
}

.history-list {
    border-top: 1px solid #333;
    padding-top: 15px;
}

.history-actions {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

.history-items {
    display: grid;
    gap: 10px;
}

.history-item {
    background: #333;
    border-radius: 5px;
    overflow: hidden;
}

.history-summary {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.3s;
}

.history-summary:hover {
    background: #444;
}

.history-info {
    flex: 1;
}

.history-name {
    font-weight: bold;
    color: #ffaa00;
    margin-bottom: 5px;
}

.history-stats {
    font-size: 12px;
    color: #ccc;
    display: flex;
    gap: 15px;
}

.history-result {
    font-weight: bold;
}

.history-result.positive {
    color: #44ff44;
}

.history-result.negative {
    color: #ff4444;
}

.history-toggle {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 12px;
    padding: 5px;
    touch-action: manipulation;
}

.history-actions-item {
    display: flex;
    gap: 10px;
    margin-left: 10px;
}

.history-actions-item button {
    background: #666;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    touch-action: manipulation;
    min-height: 44px;
}

.history-actions-item .delete-btn {
    background: #cc0000;
}

.history-actions-item .delete-btn:hover {
    background: #ff0000;
}

.history-details {
    background: #2a2a2a;
    padding: 15px;
    border-top: 1px solid #444;
    display: none;
}

.game-log {
    max-height: 200px;
    overflow-y: auto;
    background: #222;
    padding: 10px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
}

.game-entry {
    margin-bottom: 5px;
    padding: 3px 0;
    border-bottom: 1px solid #333;
}

.game-entry:last-child {
    border-bottom: none;
}

/* TABLET OPTIMIZATIONS */

/* Large Tablets (1024px - 1200px) */
@media (max-width: 1200px) and (min-width: 1024px) {
    #four-card-keno-simulator {
        padding: 15px;
        max-width: 100%;
    }
    
    .setup-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .card-performance {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .card-info-panel {
        width: 280px;
        padding: 12px;
    }
    
    .number-grid {
        height: 480px;
        padding: 8px;
    }
    
    .number-button {
        height: 54px;
        font-size: 15px;
    }
    
    .game-status-bar {
        padding: 8px 12px;
        margin-bottom: 12px;
        gap: 15px;
    }
    
    .credits-display {
        font-size: 16px;
    }
    
    #total-bet, #total-win {
        font-size: 14px;
    }
    
    .control-panel {
        padding: 12px;
        gap: 12px;
    }
    
    #draw-button {
        padding: 10px 16px !important;
        min-width: 140px;
        font-size: 14px;
    }
}

/* Standard Tablets (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
    #four-card-keno-simulator {
        padding: 12px;
    }
    
    .keno-container {
        gap: 15px;
    }
    
    .card-info-panel {
        width: 250px;
        padding: 10px;
    }
    
    .game-title {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .card-info {
        margin-bottom: 8px;
        padding: 8px;
    }
    
    .card-stats {
        font-size: 11px;
    }
    
    .card-spots {
        font-size: 9px;
        min-height: 18px;
    }
    
    .card-tabs {
        margin-bottom: 12px;
        gap: 3px;
    }
    
    .card-tab {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .number-grid {
        height: 420px;
        padding: 6px;
        gap: 1px;
        margin-bottom: 15px;
    }
    
    .number-button {
        height: 48px;
        font-size: 14px;
        border-radius: 2px;
    }
    
    .number-button:hover {
        transform: none;
    }
    
    .game-status-bar {
        padding: 8px 12px;
        margin-bottom: 12px;
        gap: 15px;
    }
    
    .credits-display {
        font-size: 16px;
    }
    
    #total-bet, #total-win {
        font-size: 14px;
    }
    
    .control-panel {
        padding: 12px;
        gap: 12px;
    }
    
    .game-controls {
        gap: 8px;
    }
    
    .game-controls button, .game-controls select {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    #draw-button {
        padding: 10px 16px !important;
        min-width: 140px;
        font-size: 14px;
    }
    
    .setup-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .card-performance {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet Portrait (768px and below) */
@media (max-width: 768px) {
    #four-card-keno-simulator {
        padding: 10px;
    }
    
    .mobile-only {
        display: block;
    }
    
    .keno-container {
        flex-direction: column;
        gap: 12px;
    }
    
    .card-info-panel {
        width: 100%;
        padding: 10px;
        order: 2;
    }
    
    .card-info-header {
        justify-content: space-between;
    }
    
    .card-info-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .card-info {
        margin-bottom: 0;
    }
    
    .game-area {
        order: 1;
    }
    
    .card-tabs {
        flex-wrap: wrap;
        gap: 4px;
        margin-bottom: 10px;
    }
    
    .card-tab {
        flex: 1;
        min-width: 80px;
        padding: 10px 8px;
        font-size: 12px;
        text-align: center;
    }
    
    .number-grid {
        grid-template-columns: repeat(10, 1fr);
        height: 360px;
        padding: 5px;
        gap: 1px;
        margin-bottom: 12px;
    }
    
    .number-button {
        height: 42px;
        font-size: 12px;
        border-radius: 2px;
    }
    
    .number-button:hover {
        transform: none;
    }
    
    .game-status-bar {
        padding: 8px;
        gap: 8px;
    }
    
    .credits-display {
        font-size: 14px;
    }
    
    #total-bet, #total-win {
        font-size: 12px;
    }
    
    .control-panel {
        padding: 10px;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .bet-controls {
        order: 1;
    }
    
    .game-controls {
        order: 2;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }
    
    #current-bet {
        font-size: 16px;
    }
    
    .setup-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .card-performance {
        grid-template-columns: 1fr;
    }
    
    .config-details {
        flex-direction: column;
        gap: 5px;
    }
    
    .history-stats {
        flex-direction: column;
        gap: 5px;
    }
}

/* Small Tablets/Large Phones (600px and below) */
@media (max-width: 600px) {
    .number-grid {
        grid-template-columns: repeat(8, 1fr);
        height: 320px;
    }
    
    .number-button {
        height: 38px;
        font-size: 11px;
    }
    
    .card-tab {
        padding: 8px 6px;
        font-size: 11px;
    }
    
    .game-controls button, .game-controls select {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    #draw-button {
        padding: 8px 12px !important;
        min-width: 120px;
        font-size: 12px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Prevent text selection and zoom on all interactive elements */
.number-button, .card-tab, .bet-controls button, .game-controls button, .game-controls select, .action-btn, .toggle-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Disable double-tap zoom */
* {
    touch-action: manipulation;
}