/* Blackjack Trainer - Dark theme, mobile-first */

:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-light: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --green: #238636;
    --green-light: #2ea043;
    --red: #da3633;
    --red-light: #f85149;
    --blue: #388bfd;
    --gold: #d29922;
    --card-white: #f0f0f0;
    --felt: #0d5016;
    --felt-light: #116620;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.header-stats {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
}

.header-stats span {
    color: var(--text-muted);
}

.header-stats .value {
    color: var(--text);
    font-weight: 600;
}

/* Mode tabs */
.mode-tabs {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.mode-tab {
    flex: 1;
    padding: 10px 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.mode-tab:hover {
    color: var(--text);
    background: var(--surface-light);
}

.mode-tab.active {
    color: var(--green-light);
    border-bottom-color: var(--green-light);
}

.mode-tab.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Table area */
.table-area {
    background: var(--felt);
    min-height: 340px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
}

/* Cards */
.hand {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    min-height: 90px;
}

.hand-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 4px;
}

.hand-value {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    text-align: center;
    margin-top: 4px;
}

.hand-value.bust {
    color: var(--red-light);
}

.hand-value.blackjack {
    color: var(--gold);
}

.card {
    width: 60px;
    height: 84px;
    background: var(--card-white);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: transform 0.2s;
}

.card.red {
    color: #cc0000;
}

.card.black {
    color: #1a1a1a;
}

.card.facedown {
    background: linear-gradient(135deg, #1a4a8a 25%, #1a3a6a 25%, #1a3a6a 50%, #1a4a8a 50%, #1a4a8a 75%, #1a3a6a 75%);
    background-size: 10px 10px;
    border: 2px solid #2a5a9a;
}

.card .rank {
    font-size: 1.2rem;
    line-height: 1;
}

.card .suit {
    font-size: 0.9rem;
    line-height: 1;
}

.card.active-hand {
    box-shadow: 0 0 0 2px var(--gold), 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Dealer section */
.dealer-section {
    text-align: center;
}

/* Player section */
.player-section {
    text-align: center;
    width: 100%;
}

.player-hands {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.player-hand-container {
    text-align: center;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.player-hand-container.active {
    opacity: 1;
}

/* Result overlay */
.result-badge {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
    display: inline-block;
}

.result-badge.win, .result-badge.blackjack {
    background: var(--green);
    color: white;
}

.result-badge.lose {
    background: var(--red);
    color: white;
}

.result-badge.push {
    background: var(--surface-light);
    color: var(--text-muted);
}

.result-badge.surrender {
    background: var(--gold);
    color: var(--bg);
}

/* Action buttons */
.actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    justify-content: center;
    flex-wrap: wrap;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-light);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    background: var(--border);
}

.btn:active {
    transform: scale(0.96);
}

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

.btn-primary {
    background: var(--green);
    border-color: var(--green);
}

.btn-primary:hover {
    background: var(--green-light);
}

.btn-danger {
    background: var(--red);
    border-color: var(--red);
}

.btn-danger:hover {
    background: var(--red-light);
}

.btn-gold {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--bg);
}

/* Strategy feedback */
.strategy-feedback {
    padding: 12px 16px;
    text-align: center;
    font-size: 0.9rem;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-bottom: 1px solid var(--border);
}

.strategy-feedback.correct {
    background: rgba(35, 134, 54, 0.15);
    color: var(--green-light);
}

.strategy-feedback.incorrect {
    background: rgba(218, 54, 51, 0.15);
    color: var(--red-light);
}

.strategy-feedback .explanation {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Bet controls */
.bet-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
}

.bet-controls .bet-amount {
    font-size: 1.5rem;
    font-weight: 700;
    min-width: 80px;
    text-align: center;
}

.bet-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-light);
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Count display */
.count-display {
    display: none;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    text-align: center;
    font-size: 0.85rem;
    gap: 24px;
    justify-content: center;
}

.count-display.visible {
    display: flex;
}

.count-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.count-item .label {
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.count-item .value {
    font-weight: 700;
    font-size: 1.1rem;
}

.count-item .value.positive {
    color: var(--green-light);
}

.count-item .value.negative {
    color: var(--red-light);
}

/* Stats panel */
.stats-panel {
    padding: 16px;
    display: none;
}

.stats-panel.visible {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 400px;
    margin: 0 auto;
}

.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.stat-box .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-box .stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 4px;
}

/* Strategy chart view */
.chart-view {
    display: none;
    padding: 16px;
    overflow-x: auto;
}

.chart-view.visible {
    display: block;
}

.chart-view h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.chart-table {
    border-collapse: collapse;
    font-size: 0.65rem;
    width: 100%;
    min-width: 340px;
}

.chart-table th, .chart-table td {
    padding: 4px 6px;
    border: 1px solid var(--border);
    text-align: center;
    min-width: 28px;
}

.chart-table th {
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 600;
}

.chart-table td.action-H { background: rgba(56, 139, 253, 0.2); color: var(--blue); }
.chart-table td.action-S { background: rgba(35, 134, 54, 0.2); color: var(--green-light); }
.chart-table td.action-D { background: rgba(210, 153, 34, 0.2); color: var(--gold); }
.chart-table td.action-P { background: rgba(163, 113, 247, 0.2); color: #a371f7; }
.chart-table td.action-R { background: rgba(218, 54, 51, 0.2); color: var(--red-light); }

/* Responsive */
@media (min-width: 480px) {
    .card {
        width: 72px;
        height: 100px;
        font-size: 1.3rem;
    }

    .card .rank { font-size: 1.4rem; }
    .card .suit { font-size: 1.1rem; }

    .table-area {
        min-height: 380px;
        padding: 24px;
    }
}

@media (min-width: 768px) {
    .table-area {
        min-height: 420px;
    }
}

/* Animations */
@keyframes dealCard {
    from {
        opacity: 0;
        transform: translateY(-30px) rotate(-5deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(0);
    }
}

.card.deal-anim {
    animation: dealCard 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Settings toggle area */
.settings-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}

.toggle-group {
    display: flex;
    gap: 16px;
    align-items: center;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-muted);
}

.toggle input {
    display: none;
}

.toggle .switch {
    width: 36px;
    height: 20px;
    background: var(--border);
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
}

.toggle .switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text);
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle input:checked + .switch {
    background: var(--green);
}

.toggle input:checked + .switch::after {
    transform: translateX(16px);
}

/* Streak indicator */
.streak {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 4px;
}

.streak.hot {
    color: var(--gold);
}
