/* ==========================================================================
   Blackjack Basic Strategy Trainer - Modern Casino Design System
   ========================================================================== */

:root {
    --bg-dark: #07130e;
    --felt-dark: #08311f;
    --felt-light: #104f32;
    --felt-pattern: rgba(0, 0, 0, 0.15);
    
    --gold-primary: #f59e0b;
    --gold-light: #fbbf24;
    --gold-glow: rgba(245, 158, 11, 0.4);
    
    --card-white: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.45);
    --card-red: #dc2626;
    --card-black: #1e293b;
    
    --color-hit: #10b981;
    --color-hit-hover: #059669;
    --color-stand: #ef4444;
    --color-stand-hover: #dc2626;
    --color-double: #0284c7;
    --color-double-hover: #0369a1;
    --color-split: #8b5cf6;
    --color-split-hover: #7c3aed;
    
    --color-correct: #10b981;
    --color-wrong: #ef4444;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --surface-glass: rgba(15, 23, 42, 0.75);
    --surface-card: rgba(17, 24, 39, 0.85);
    --surface-border: rgba(255, 255, 255, 0.12);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Login Screen
   ========================================================================== */
.login-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 50% 40%, var(--felt-dark) 0%, var(--bg-dark) 80%);
}

.login-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(245, 158, 11, 0.1);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 36px 28px;
    text-align: center;
    animation: slideUp 0.4s ease-out;
}

.login-icon-badge {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.05));
    border: 1px solid var(--gold-primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 0 20px var(--gold-glow);
}

.login-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #fff, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    position: relative;
    text-align: left;
}

.input-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.password-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition-smooth);
    text-align: center;
}

.password-input:focus {
    border-color: var(--gold-primary);
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 16px var(--gold-glow);
}

.btn-login {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
    color: #1a1300;
    border: none;
    font-size: 0.95rem;
    font-weight: 800;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 6px 18px var(--gold-glow);
    transition: var(--transition-smooth);
    margin-top: 4px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.6);
}

.login-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--color-wrong);
    color: #fca5a5;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ==========================================================================
   Header Navigation & Collapsible Settings Bar
   ========================================================================== */
.app-header {
    background: rgba(7, 19, 14, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--surface-border);
    padding: 8px 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    transition: all 0.25s ease;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    font-size: 1.4rem;
    color: var(--gold-primary);
    filter: drop-shadow(0 0 6px var(--gold-glow));
}

.brand-text h1 {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}

.brand-text span {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
}

.header-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Minimized status pill */
.active-summary-pill {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--gold-light);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    display: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.app-header.collapsed .active-summary-pill {
    display: inline-block;
}

/* Toggle Settings Button */
.btn-toggle-settings {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--surface-border);
    color: var(--gold-light);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.btn-toggle-settings:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--gold-primary);
}

/* Collapsible Settings Controls Row */
.header-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    max-height: 250px;
    opacity: 1;
    overflow: visible;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, padding 0.25s ease;
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

/* Complete hide when collapsed */
.app-header.collapsed .header-controls {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border-top: none;
    pointer-events: none;
}

/* Mode Switchers */
.mode-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--surface-border);
    padding: 2px;
    border-radius: var(--radius-full);
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.mode-btn.active {
    background: var(--gold-primary);
    color: #000;
    box-shadow: 0 2px 6px var(--gold-glow);
}

.select-wrapper {
    position: relative;
}

.custom-select {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
    transition: var(--transition-smooth);
}

.custom-select:hover, .custom-select:focus {
    border-color: var(--gold-primary);
    background: rgba(255, 255, 255, 0.1);
}

.custom-select option {
    background: #0f172a;
    color: #fff;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
    text-decoration: none;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--gold-primary);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--gold-primary);
}

.btn-logout {
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    font-size: 0.75rem;
    padding: 5px 10px;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

/* ==========================================================================
   Main Game Area
   ========================================================================== */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 10px 14px 24px;
    gap: 12px;
}

/* Stats HUD */
.stats-hud {
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-item:last-child {
    border-right: none;
}

.stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 1px;
    font-feature-settings: "tnum";
}

.stat-value.highlight {
    color: var(--gold-light);
}

.stat-value.success {
    color: var(--color-hit);
}

.stat-value.danger {
    color: var(--color-stand);
}

.streak-flame {
    color: #f97316;
    margin-right: 2px;
}

/* Felt Blackjack Table */
.blackjack-table {
    background: radial-gradient(circle at 50% 30%, var(--felt-light) 0%, var(--felt-dark) 80%, #04190f 100%);
    border: 6px solid #2b1d11;
    box-shadow: 
        inset 0 0 60px rgba(0, 0, 0, 0.7),
        0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 120px 120px 28px 28px;
    padding: 24px 20px 28px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 460px;
    overflow: hidden;
}

.table-felt-print {
    text-align: center;
    pointer-events: none;
    user-select: none;
    margin-bottom: 12px;
}

.table-rule-title {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(251, 191, 36, 0.65);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.table-rule-sub {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 2px;
}

.table-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    margin-bottom: 14px;
}

.zone-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.zone-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-badge {
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid var(--gold-primary);
    color: var(--gold-light);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    min-width: 38px;
    text-align: center;
}

.cards-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    min-height: 100px;
    perspective: 1000px;
    flex-wrap: wrap;
}

.player-hands-wrapper {
    display: flex;
    justify-content: center;
    gap: 16px;
    width: 100%;
    flex-wrap: wrap;
}

.hand-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: var(--transition-smooth);
    border: 1px dashed transparent;
}

.hand-box.active-hand {
    background: rgba(251, 191, 36, 0.08);
    border-color: var(--gold-primary);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.2);
}

/* CSS Cards */
.card-item {
    width: 68px;
    height: 100px;
    background: var(--card-white);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 10px var(--card-shadow), 0 1px 3px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 5px;
    position: relative;
    user-select: none;
    animation: cardDeal 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) backwards;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
}

.card-item.red {
    color: var(--card-red);
}

.card-item.black {
    color: var(--card-black);
}

.card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    font-weight: 800;
}

.card-corner .rank {
    font-size: 0.88rem;
}

.card-corner .suit {
    font-size: 0.72rem;
    margin-top: 1px;
}

.card-corner.bottom {
    transform: rotate(180deg);
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.7rem;
    opacity: 0.9;
}

.card-item.hidden-card {
    background: repeating-linear-gradient(
        45deg,
        #1e3a8a,
        #1e3a8a 6px,
        #172554 6px,
        #172554 12px
    );
    border: 2px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
}

.card-item.hidden-card::after {
    content: "♠♥♦♣";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.65rem;
    letter-spacing: 1px;
}

@keyframes cardDeal {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(0.85) rotate(-6deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
    }
}

/* Action Controls Bar */
.action-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 10;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}

.action-btn {
    border: none;
    color: #ffffff;
    font-weight: 800;
    font-size: 0.95rem;
    padding: 10px 22px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transition: var(--transition-smooth);
    position: relative;
    min-width: 90px;
}

.action-btn .btn-shortcut {
    font-size: 0.6rem;
    opacity: 0.75;
    font-weight: 500;
    text-transform: uppercase;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.action-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(80%);
    box-shadow: none;
}

.btn-hit {
    background: linear-gradient(135deg, var(--color-hit), var(--color-hit-hover));
}

.btn-stand {
    background: linear-gradient(135deg, var(--color-stand), var(--color-stand-hover));
}

.btn-double {
    background: linear-gradient(135deg, var(--color-double), var(--color-double-hover));
}

.btn-split {
    background: linear-gradient(135deg, var(--color-split), var(--color-split-hover));
}

.btn-primary-action {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
    color: #1a1300;
    border: none;
    font-size: 0.95rem;
    font-weight: 800;
    padding: 10px 28px;
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: 0 4px 14px var(--gold-glow);
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary-action:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
}

.bet-controls {
    display: none;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.bet-controls.visible {
    display: flex;
}

.chip-btn {
    background: #1e293b;
    border: 2px dashed var(--gold-primary);
    color: var(--gold-light);
    font-weight: 800;
    font-size: 0.75rem;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.chip-btn:hover {
    background: var(--gold-primary);
    color: #000;
    transform: scale(1.1);
}

/* Feedback Card */
.feedback-container {
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

.feedback-card {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.feedback-card.correct {
    border-left: 5px solid var(--color-correct);
}

.feedback-card.wrong {
    border-left: 5px solid var(--color-wrong);
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 6px;
}

.status-badge {
    font-size: 0.88rem;
    font-weight: 800;
    padding: 3px 12px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.status-badge.correct {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-correct);
    border: 1px solid var(--color-correct);
}

.status-badge.wrong {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-wrong);
    border: 1px solid var(--color-wrong);
}

.hand-context-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}

.feedback-summary {
    font-size: 0.95rem;
    margin-bottom: 10px;
    line-height: 1.4;
}

.feedback-explanation {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #cbd5e1;
    margin-bottom: 10px;
    border-left: 3px solid var(--gold-primary);
}

.feedback-ev-tip {
    font-size: 0.78rem;
    color: var(--gold-light);
    display: flex;
    align-items: flex-start;
    gap: 6px;
    background: rgba(245, 158, 11, 0.08);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.round-outcome-banner {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    font-weight: 700;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.modal-backdrop.open {
    display: flex;
}

.modal-dialog {
    background: #0f172a;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: #0f172a;
    z-index: 10;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gold-light);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 16px 20px 24px;
}

.chart-legend {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
}

.legend-color {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: #fff;
}

.chart-section {
    margin-bottom: 20px;
}

.chart-section h3 {
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.strategy-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.strategy-table th, .strategy-table td {
    padding: 6px 3px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.strategy-table th {
    background: rgba(255, 255, 255, 0.06);
    color: var(--gold-light);
    font-weight: 700;
}

.strategy-table td.cell-H {
    background: rgba(16, 185, 129, 0.8);
    color: #ffffff;
    font-weight: 700;
}

.strategy-table td.cell-S {
    background: rgba(239, 68, 68, 0.8);
    color: #ffffff;
    font-weight: 700;
}

.strategy-table td.cell-D {
    background: rgba(2, 132, 199, 0.8);
    color: #ffffff;
    font-weight: 700;
}

.strategy-table td.cell-P {
    background: rgba(139, 92, 246, 0.8);
    color: #ffffff;
    font-weight: 700;
}

.strategy-table td.highlight-cell {
    outline: 3px solid #fbbf24;
    position: relative;
    z-index: 2;
    transform: scale(1.12);
    box-shadow: 0 0 12px #fbbf24;
}

.app-footer {
    padding: 12px 16px;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-dim);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* ==========================================================================
   Mobile-Specific Optimizations (Smartphones & Tablets)
   ========================================================================== */
@media (max-width: 768px) {
    .app-header {
        padding: 6px 12px;
    }

    .brand-text span {
        display: none; /* Hide subtitle on mobile to save vertical space */
    }

    .brand-text h1 {
        font-size: 0.95rem;
    }

    .brand-icon {
        font-size: 1.2rem;
    }

    /* Make toggle button very clean on mobile */
    .btn-toggle-settings {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    .active-summary-pill {
        display: none !important; /* Hide summary pill on mobile to prevent overflow */
    }

    .main-wrapper {
        padding: 6px 8px 16px;
        gap: 8px;
    }

    /* Ultra Compact Stats HUD on Mobile */
    .stats-hud {
        padding: 6px 8px;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }

    /* Compact Blackjack Felt Table for Mobile Screens */
    .blackjack-table {
        border-width: 4px;
        border-radius: 24px;
        padding: 14px 10px 18px;
        min-height: 380px;
    }

    .table-felt-print {
        margin-bottom: 6px;
    }

    .table-rule-title {
        font-size: 0.7rem;
    }

    .table-rule-sub {
        display: none; /* Hide sub-rules print on mobile */
    }

    .table-zone {
        margin-bottom: 8px;
    }

    .zone-header {
        margin-bottom: 4px;
    }

    /* Cards Scaled for Mobile */
    .card-item {
        width: 52px;
        height: 78px;
        padding: 3px;
        border-radius: 6px;
    }

    .card-corner .rank {
        font-size: 0.78rem;
    }

    .card-corner .suit {
        font-size: 0.62rem;
    }

    .card-center {
        font-size: 1.2rem;
    }

    .cards-container {
        gap: 6px;
        min-height: 80px;
    }

    /* Action Buttons in 2x2 grid on very small screens or 4-in-a-row */
    .action-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        width: 100%;
        max-width: 320px;
    }

    .action-btn {
        padding: 10px 8px;
        font-size: 0.88rem;
        min-width: unset;
        width: 100%;
    }

    .action-btn .btn-shortcut {
        display: none; /* Hide keyboard shortcut text on mobile */
    }

    .btn-primary-action {
        width: 100%;
        max-width: 320px;
        justify-content: center;
        padding: 12px 16px;
        font-size: 0.95rem;
    }

    .feedback-card {
        padding: 12px 14px;
    }

    .feedback-summary {
        font-size: 0.88rem;
    }

    .feedback-explanation {
        font-size: 0.8rem;
        padding: 8px 10px;
    }

    .feedback-ev-tip {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    /* Auto-collapse settings bar completely on small mobile devices by default */
    .header-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .custom-select {
        width: 100%;
    }

    .mode-selector {
        width: 100%;
    }

    .mode-btn {
        flex: 1;
        justify-content: center;
    }
}
