@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

html { height: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    background: #0a0a12;
    color: #e0e0e0;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ── Top Header Bar ── */
.top-bar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: linear-gradient(180deg, #1a1a3a 0%, #0e0e20 100%);
    border-bottom: 2px solid rgba(42, 42, 80, 0.5);
    position: sticky;
    top: 0;
    z-index: 200;
    gap: 12px;
    flex-wrap: wrap;
}
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.top-bar-game {
    display: flex;
    align-items: center;
    gap: 8px;
}
.top-bar-game select {
    display: none;
}
/* Game picker button */
.game-picker-btn {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    padding: 5px 12px;
    background: #1a1a3a;
    color: #44ddff;
    border: 1px solid #44ddff;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.game-picker-btn:hover { background: #222250; }
.gpb-ev {
    font-size: 12px;
    font-weight: 600;
    color: #88aacc;
}
.gpb-arrow {
    font-size: 10px;
    color: #44ddff;
    margin-left: 2px;
}

/* ── Game Picker Modal ── */
.gp-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 500;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
}
.gp-overlay.open { display: flex; }
.gp-modal {
    background: linear-gradient(180deg, #1a1a3a 0%, #0e0e20 100%);
    border: 1px solid rgba(42, 42, 80, 0.5);
    border-radius: 12px;
    width: 440px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 100px);
    max-height: calc(100dvh - 100px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}
.gp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(42, 42, 80, 0.5);
}
.gp-title {
    font-size: 14px;
    font-weight: 700;
    color: #44ddff;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.gp-close {
    font-size: 18px;
    color: #556688;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px 8px;
    line-height: 1;
}
.gp-close:hover { color: #88aacc; }
.gp-tabs {
    display: flex;
    border-bottom: 1px solid rgba(42, 42, 80, 0.5);
    overflow-x: auto;
    flex-shrink: 0;
}
.gp-tab {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 8px 14px;
    background: transparent;
    color: #5588aa;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.gp-tab:hover { color: #88aacc; }
.gp-tab.active {
    color: #44ddff;
    border-bottom-color: #44ddff;
}
.gp-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding: 8px 0;
}
.gp-group-header {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #5588aa;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 8px 16px 4px;
}
.gp-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 16px 7px 24px;
    cursor: pointer;
    transition: background 0.1s;
    gap: 8px;
}
.gp-item:hover { background: rgba(50, 80, 150, 0.12); }
.gp-item.selected {
    background: rgba(68, 221, 255, 0.08);
    border-left: 3px solid #44ddff;
    padding-left: 21px;
}
.gp-item-label {
    font-size: 15px;
    font-weight: 600;
    color: #88aacc;
}
.gp-item.selected .gp-item-label { color: #44ddff; }
.gp-item-ev {
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #88aacc;
    white-space: nowrap;
}
.gp-item-ev.positive { color: #00dd44; }

.mode-tabs {
    display: flex;
    gap: 0;
}
.mode-tab {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 6px 18px;
    background: transparent;
    color: #5588aa;
    border: 1px solid #2a2a50;
    border-right: none;
    cursor: pointer;
    transition: all 0.15s;
}
.mode-tab:first-child { border-radius: 4px 0 0 4px; }
.mode-tab:last-child { border-radius: 0 4px 4px 0; border-right: 1px solid #2a2a50; }
.mode-tab:hover { color: #88aacc; background: rgba(40,40,80,0.3); }
.mode-tab.active {
    color: #44ddff;
    background: rgba(68, 221, 255, 0.1);
    border-color: #44ddff;
}
.mode-tab.active + .mode-tab { border-left-color: #44ddff; }
.mode-tab:disabled { opacity: 0.4; cursor: default; }

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 20px;
    font-weight: 600;
}
.top-bar-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}
.top-bar-stat .stat-label {
    color: #556688;
    font-size: 17px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.top-bar-stat .stat-value { color: #88aacc; }
.top-bar-stat .stat-value.green { color: #00dd44; }
.top-bar-stat .stat-value.orange { color: #ff8844; }

/* ── Auth UI ── */
.top-bar-user { display: flex; align-items: center; gap: 8px; }
.login-btn {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 14px;
    background: transparent;
    color: #44ddff;
    border: 1px solid #44ddff;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.login-btn:hover { background: #1a1a3a; }
.user-name {
    font-size: 13px;
    color: #88aacc;
    font-weight: 600;
}
.user-tier {
    font-size: 11px;
    color: #44ddff;
    background: #1a1a3a;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}
.logout-btn {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    padding: 3px 8px;
    background: transparent;
    color: #556688;
    border: 1px solid #2a2a50;
    border-radius: 3px;
    cursor: pointer;
}
.logout-btn:hover { color: #ff6655; border-color: #ff6655; }

/* ── Two-Column Layout ── */
.main-area {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px); /* iOS/iPadOS Safari: dynamic viewport height */
    align-items: stretch;
}

/* ── Right Column Container (Strategy + Paytable stacked) ── */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    height: 100%;
}

/* ── Strategy Panel ── */
.panel-strategy {
    background: linear-gradient(180deg, #1a1a3a 0%, #0e0e20 100%);
    border: 1px solid rgba(42, 42, 80, 0.5);
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.strat-scroll {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.strat-header {
    padding: 10px 14px;
    background: rgba(0, 20, 60, 0.6);
    border-bottom: 1px solid rgba(42, 42, 80, 0.5);
    font-size: 12px;
    font-weight: 700;
    color: #44ddff;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.strat-empty {
    padding: 20px 14px;
    color: #556688;
    font-size: 13px;
    text-align: center;
    line-height: 1.5;
}
.strat-list {
    padding: 0;
}
.strat-option {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(42, 42, 80, 0.5);
    cursor: pointer;
    transition: background 0.1s;
}
.strat-option:hover {
    background: rgba(50, 80, 150, 0.12);
}
.strat-option.optimal {
    background: rgba(68, 221, 255, 0.06);
    border-left: 3px solid #44ddff;
}
.strat-option.player-match {
    background: rgba(255, 220, 0, 0.06);
    border-left: 3px solid #ffdd00;
}
.strat-option.optimal.player-match {
    background: rgba(68, 221, 255, 0.08);
    border-left: 3px solid #00dd44;
}
.strat-rank-line {
    display: flex;
    align-items: center;
    gap: 6px;
}
.strat-rank-num {
    font-size: 16px;
    color: #556688;
    min-width: 28px;
}
.strat-rank-num.best {
    color: #44ddff;
}
.strat-hold-desc {
    font-size: 18px;
    font-weight: 600;
    color: #88aacc;
}
.strat-option.optimal .strat-hold-desc { color: #44ddff; }
.strat-ev {
    font-size: 18px;
    font-weight: 700;
    color: #88aacc;
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}
.strat-option.optimal .strat-ev { color: #44ddff; }
.strat-mini-cards {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.strat-mini-cards .mc {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 2px;
    min-width: 22px;
    text-align: center;
    border-radius: 2px;
    background: #fff;
    border: 1px solid #bbb;
}
.strat-mini-cards .mc.mc-red { color: #cc0000; }
.strat-mini-cards .mc.mc-black { color: #111; }
.strat-mini-cards .mc.mc-held {
    background: #fff;
    box-shadow: none;
}
.strat-mini-cards .mc-facedown {
    min-width: 22px;
    min-height: 16px;
    background: linear-gradient(135deg, #2a3a6a 0%, #1a2a50 100%);
    border: 1px solid #3a4a7a;
}
.strat-cards-line {
    font-size: 14px;
    color: #556688;
    margin-top: 1px;
}
.strat-diff {
    font-size: 13px;
    margin-top: 0;
}
.strat-diff.negative { color: #ff6655; }
.strat-diff.neutral { color: #556688; }

/* ── Game Panel (left/main column) ── */
.panel-game {
    background: linear-gradient(180deg, #1a1a3a 0%, #0e0e20 100%);
    border: 2px solid rgba(42, 42, 80, 0.5);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(30, 30, 80, 0.4);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Game content area (multi-hand + banner + cards) — fills available space */
.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Win Banner */
.win-banner {
    text-align: center;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 4px 0;
    background: linear-gradient(180deg, #0e0e20 0%, #0a0a12 100%);
    flex-shrink: 0;
    overflow: hidden;
}
.win-banner .hand-name {
    font-size: 26px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #FFD700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 215, 0, 0.4);
    animation: winPulse 0.8s ease-in-out infinite alternate;
}
.win-banner .win-amount {
    font-size: 16px;
    font-weight: 600;
    color: #00dd44;
    text-shadow: 0 0 12px rgba(0, 221, 68, 0.6);
    margin-top: 2px;
}
.win-banner .dealt-hand-name {
    font-size: 15px;
    font-weight: 600;
    color: #FFD700;
    opacity: 0.9;
}
@keyframes winPulse {
    from { opacity: 1; }
    to { opacity: 0.7; }
}

/* Card Area */
.card-area {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 14px 0 4px;
    background: transparent;
    position: relative;
}
.card-slot {
    text-align: center;
    position: relative;
}

/* ── Realistic Card Design ── */
.card {
    width: 120px;
    height: 168px;
    border-radius: 8px;
    user-select: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    overflow: hidden;
}
.card.empty {
    background: repeating-linear-gradient(
        45deg,
        #161638, #161638 4px,
        #1a1a3a 4px, #1a1a3a 8px
    );
    border: 2px solid rgba(42, 42, 80, 0.5);
    cursor: default;
}

.card.face-up {
    background: #fff;
    border: 1.5px solid #aaa;
    box-shadow: 1px 2px 6px rgba(0,0,0,0.45);
}
.card.face-up.black { color: #222; }
.card.face-up.red { color: #d40000; }

/* Inner card margin line */
.card-inner {
    position: absolute;
    top: 2px; left: 2px; right: 2px; bottom: 2px;
    border: 1px solid rgba(0,0,0,0.07);
    border-radius: 6px;
    pointer-events: none;
}

/* Corner indicators */
.card-tl {
    position: absolute;
    top: 4px;
    left: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    z-index: 2;
}
.card-br {
    position: absolute;
    bottom: 4px;
    right: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    transform: rotate(180deg);
    z-index: 2;
}
.card-corner-rank {
    font-size: 24px;
    font-weight: 800;
    font-family: 'Georgia', 'Times New Roman', serif;
}
.card-corner-suit {
    font-size: 18px;
    margin-top: -2px;
}

/* Center suit - single giant pip for all cards */
.card-center-suit {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 112px;
    line-height: 1;
    z-index: 1;
}
/* Face cards: large rank letter + suit below */
.card.face-up .card-center-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
}
.card-center-face .face-letter {
    font-size: 52px;
    font-weight: 800;
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1;
}
.card-center-face .face-suit {
    font-size: 30px;
    line-height: 1;
    margin-top: -2px;
}

/* Win overlay on card area */
.win-overlay {
    display: none;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.88);
    border: 2px solid #555;
    border-radius: 8px;
    padding: 8px 20px;
    text-align: center;
    z-index: 20;
    pointer-events: none;
}
.win-overlay.visible { display: block; }
.win-overlay .wo-name {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}
.win-overlay .wo-pay {
    color: #FFD700;
    font-size: 14px;
    font-weight: 700;
}

/* Split card slot: smaller cards, back card 3 corners visible */
.card-slot.split-slot {
    width: 150px;
}
.split-cards {
    position: relative;
    width: 150px;
    height: 168px;
}
.split-cards .card {
    position: absolute;
    width: 100px;
    height: 140px;
}
/* Scale down inner elements for smaller split cards */
.split-cards .card .card-center-suit { font-size: 44px; }
.split-cards .card .card-center-face .face-letter { font-size: 36px; }
.split-cards .card .card-center-face .face-suit { font-size: 20px; }
.split-cards .card .card-corner-rank { font-size: 13px; }
.split-cards .card .card-corner-suit { font-size: 9px; margin-top: 0; }
/* Second card: behind, offset right so top-left, top-right, bottom-right corners show */
.split-cards .card.split-back {
    top: 0;
    left: 50px;
    z-index: 1;
}
/* Base card: in front, offset down+left so back card's top corners peek out */
.split-cards .card.split-front {
    top: 28px;
    left: 0;
    z-index: 2;
}
.split-cards .card.face-up.held.split-front {
    transform: translateY(-10px);
}
.split-cards .card.face-up.held.split-back {
    transform: translateY(-10px);
}
.split-badge {
    position: absolute;
    top: -4px;
    right: 0;
    background: linear-gradient(135deg, #ff6600, #ff3300);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 8px;
    z-index: 10;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.dream-badge {
    position: absolute;
    top: -4px;
    right: 0;
    background: linear-gradient(135deg, #cc8800, #aa6600);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 8px;
    z-index: 10;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* Held state */
.card.face-up.held {
    transform: translateY(-10px);
    border-color: #FFDD00;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.35), 2px 3px 10px rgba(0,0,0,0.5);
}
/* Drawn card (new after draw) */
.card.face-up.drawn-card {
    border-color: #00CC66;
    box-shadow: 0 0 14px rgba(0, 204, 102, 0.25), 2px 3px 10px rgba(0,0,0,0.5);
}

/* Wild deuce card — gold background with WILD banner, as seen on real DW machines */
.card.face-up.wild-deuce {
    background: linear-gradient(160deg, #fff9d0 0%, #ffd700 55%, #ffaa00 100%);
    border-color: #c88000;
    box-shadow: 0 0 12px rgba(255, 200, 0, 0.5), 1px 2px 6px rgba(0,0,0,0.45);
    color: #6b3a00;
}
.card.face-up.wild-deuce.held {
    border-color: #c88000;
    box-shadow: 0 0 22px rgba(255, 180, 0, 0.7), 2px 3px 10px rgba(0,0,0,0.5);
}
.wild-banner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 3px;
    color: #fff;
    background: #b85c00;
    padding: 3px 0 2px;
    z-index: 3;
    font-family: 'Inter', sans-serif;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Hold label below card */
.hold-label {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
}
.hold-label.held-text {
    color: #FFDD00;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
}
.hold-label.drawn-text {
    color: #00cc66;
    font-size: 12px;
    letter-spacing: 1px;
    opacity: 0.7;
}

/* EV Tooltip on card hover */
.ev-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 10, 30, 0.95);
    border: 1px solid #2a2a50;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.8);
    pointer-events: none;
}
.ev-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2a2a50;
}
.card-slot:hover .ev-tooltip { display: block; }
.ev-tooltip .ev-val { color: #44ddff; font-weight: 700; font-size: 14px; }
.ev-tooltip .ev-label { color: #88aacc; }
.ev-tooltip .ev-diff { font-size: 11px; margin-top: 2px; }
.ev-tooltip .ev-diff.negative { color: #ff6655; }
.ev-tooltip .ev-diff.positive { color: #00dd44; }
.ev-tooltip .ev-diff.neutral { color: #556688; }

/* ── Advisor Hint (below cards) ── */
.advisor-hint {
    display: none;
    text-align: center;
    padding: 6px 12px;
    background: rgba(0, 20, 60, 0.5);
    border-top: 1px solid rgba(42, 42, 80, 0.5);
    font-size: 13px;
}
.advisor-hint.visible { display: block; }
.advisor-hint .hint-label {
    font-size: 10px;
    color: #5588aa;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.advisor-hint .hint-rec {
    color: #44ddff;
    font-weight: 600;
}
.advisor-hint .hint-ev {
    color: #88aacc;
    margin-left: 6px;
    font-size: 12px;
}

/* ── Bottom Controls ── */
.bottom-controls {
    background: linear-gradient(180deg, #0e0e20 0%, #0a0a12 100%);
    border-top: 1px solid rgba(42, 42, 80, 0.5);
    padding: 6px 12px;
    flex-shrink: 0;
}
.bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.bottom-left {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 18px;
    font-weight: 700;
}
.bottom-left .win-display {
    color: #FFD700;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.bottom-left .win-display .lbl { font-size: 15px; letter-spacing: 1px; opacity: 0.8; }
.bottom-left .bet-display {
    color: #FFD700;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.bottom-left .bet-display .lbl { font-size: 15px; letter-spacing: 1px; opacity: 0.8; }
.bottom-center {
    display: flex;
    align-items: center;
    gap: 6px;
}
.bottom-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
}
.bottom-right .credits-display {
    color: #00dd44;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.bottom-right .credits-display .lbl { font-size: 15px; letter-spacing: 1px; opacity: 0.8; }

/* Buttons */
.game-btn {
    font-family: 'Inter', sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 10px 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.game-btn:disabled { opacity: 0.3; cursor: default; }
.deal-btn, .action-btn-deal {
    background: linear-gradient(180deg, #cc2222 0%, #991111 100%);
    color: #fff;
    box-shadow: 0 3px 0 #660000, 0 4px 12px rgba(0,0,0,0.5);
}
.deal-btn:hover:not(:disabled), .action-btn-deal:hover:not(:disabled) {
    background: linear-gradient(180deg, #dd3333 0%, #aa2222 100%);
}
.deal-btn:active:not(:disabled), .action-btn-deal:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #660000;
}
.draw-btn, .action-btn-draw {
    background: linear-gradient(180deg, #2266cc 0%, #1144aa 100%);
    color: #fff;
    box-shadow: 0 3px 0 #0a2266, 0 4px 12px rgba(0,0,0,0.5);
}
.draw-btn:hover:not(:disabled), .action-btn-draw:hover:not(:disabled) {
    background: linear-gradient(180deg, #3377dd 0%, #2255bb 100%);
}
.draw-btn:active:not(:disabled), .action-btn-draw:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #0a2266;
}

.select-wrap {
    position: relative;
}
.select-wrap select {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 26px 7px 10px;
    background: #1a1a3a;
    color: #88aacc;
    border: 1px solid #2a2a50;
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    letter-spacing: 0.5px;
}
.select-wrap::after {
    content: '\25BC';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #5588aa;
    font-size: 9px;
    pointer-events: none;
}

/* Hand Count Stepper */
.hand-count-stepper {
    display: flex;
    align-items: center;
    gap: 2px;
}
.hand-count-stepper .hc-label {
    font-size: 11px;
    color: #5588aa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-right: 4px;
}
.hc-arrow {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    color: #5588aa;
    border: 1px solid #2a2a50;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
}
.hc-arrow:hover:not(:disabled) { color: #44ddff; background: rgba(40,40,80,0.5); }
.hc-arrow:disabled { opacity: 0.3; cursor: default; }
.hc-value {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #44ddff;
    min-width: 32px;
    text-align: center;
    background: rgba(0,0,0,0.3);
    border: 1px solid #44ddff;
    border-radius: 4px;
    padding: 2px 4px;
    line-height: 1;
}

/* Credits Input */
.credits-input-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}
.credits-input-label {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #22aa44;
}
.credits-input {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    width: 72px;
    text-align: center;
    padding: 5px 6px;
    border: 2px solid #22aa44;
    border-radius: 6px;
    background: #0a1a10;
    color: #00dd44;
    outline: none;
}
.credits-input:focus {
    border-color: #44dd66;
    box-shadow: 0 0 8px rgba(34, 170, 68, 0.4);
}
.no-bankrupt-label {
    font-size: 11px;
    color: #5588aa;
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    user-select: none;
}
.no-bankrupt-label input { accent-color: #44ddff; cursor: pointer; }

/* ── Mode Panels (Training / Auto-Play overlays below bottom bar) ── */
.mode-panel {
    border-top: 1px solid rgba(42, 42, 80, 0.5);
    overflow: hidden;
}
.mode-panel > div {
    display: none;
}

/* Training Panel */
.training-panel {
    padding: 10px 16px;
    background: rgba(0, 30, 20, 0.6);
    border-top: 1px solid #1a4a30;
}
.training-panel.visible { display: flex !important; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.training-label {
    font-size: 11px;
    color: #44aa66;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.training-stat {
    font-weight: 700;
    font-size: 16px;
    color: #00dd44;
}
.training-detail { color: #5588aa; font-size: 12px; }
.training-streak { color: #88aacc; font-size: 12px; }
.training-evlost { color: #ff6655; font-size: 12px; }
.training-reset {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    padding: 3px 8px;
    background: rgba(0,0,0,0.3);
    color: #5588aa;
    border: 1px solid #2a2a50;
    border-radius: 4px;
    cursor: pointer;
}
.training-reset:hover { color: #88aacc; background: rgba(40,40,80,0.4); }
.training-separator { width: 1px; height: 16px; background: #2a4a40; }
.training-warn-label { font-size: 11px; color: #44aa66; text-transform: uppercase; letter-spacing: 1px; }
.train-warn-select {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    padding: 2px 6px;
    background: rgba(0,0,0,0.4);
    color: #88aacc;
    border: 1px solid #2a4a40;
    border-radius: 4px;
    cursor: pointer;
}
.train-warn-select:hover { border-color: #44aa66; }
.training-warning-banner {
    display: none;
    padding: 8px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    animation: warn-pulse 0.3s ease-out;
}
.training-warning-banner.visible { display: block; }
.training-warning-banner.serious {
    background: rgba(180, 40, 20, 0.5);
    border-top: 1px solid #cc3322;
    color: #ff6644;
}
.training-warning-banner.minor {
    background: rgba(160, 120, 20, 0.4);
    border-top: 1px solid #aa8822;
    color: #ddaa33;
}
@keyframes warn-pulse {
    0% { opacity: 0; transform: scaleY(0.8); }
    100% { opacity: 1; transform: scaleY(1); }
}

/* Auto-Play Panel */
.autoplay-panel {
    padding: 10px 16px;
    background: rgba(0, 10, 30, 0.8);
}
.autoplay-panel.visible { display: block !important; }
.ap-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}
.ap-row label {
    font-size: 13px;
    color: #88aacc;
}
.ap-row input[type="number"] {
    font-family: 'Inter', sans-serif;
    width: 80px;
    padding: 4px 8px;
    background: #1a1a3a;
    color: #88aacc;
    border: 1px solid #2a2a50;
    border-radius: 4px;
    font-size: 13px;
}
.ap-speed { display: flex; align-items: center; gap: 5px; }
.ap-speed-btn {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    padding: 4px 9px;
    background: rgba(0,0,0,0.4);
    color: #5588aa;
    border: 1px solid #2a2a50;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.ap-speed-btn.active { color: #44ddff; border-color: #44ddff; }
.ap-speed-btn:hover { color: #88aacc; }
input[type="range"] { width: 90px; accent-color: #44ddff; }
#ap-delay-label { font-size: 11px; color: #5588aa; min-width: 38px; }

.ap-start-btn {
    background: linear-gradient(180deg, #22aa44 0%, #118833 100%) !important;
    color: #fff; font-size: 13px !important; padding: 7px 20px !important;
    box-shadow: 0 3px 0 #0a5522, 0 4px 12px rgba(0,0,0,0.5);
}
.ap-start-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #33bb55 0%, #22aa44 100%) !important;
}
.ap-pause-btn {
    background: linear-gradient(180deg, #cc8800 0%, #aa6600 100%) !important;
    color: #fff; font-size: 13px !important; padding: 7px 20px !important;
    box-shadow: 0 3px 0 #664400, 0 4px 12px rgba(0,0,0,0.5);
}
.ap-stop-btn {
    background: linear-gradient(180deg, #cc2222 0%, #991111 100%) !important;
    color: #fff; font-size: 13px !important; padding: 7px 14px !important;
    box-shadow: 0 3px 0 #660000, 0 4px 12px rgba(0,0,0,0.5);
}

/* Auto-play progress bar */
.ap-progress {
    display: none;
    margin-top: 8px;
}
.ap-progress-track {
    width: 100%;
    height: 16px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(42, 42, 80, 0.5);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}
.ap-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1155aa 0%, #44ddff 100%);
    border-radius: 7px;
    width: 0%;
    transition: width 0.15s ease;
    box-shadow: 0 0 8px rgba(68, 221, 255, 0.4);
}
.ap-progress-text {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Card Area Overlay (instant mode) */
.card-area-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 10, 30, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #44ddff;
    letter-spacing: 2px;
    text-transform: uppercase;
    z-index: 50;
}

/* ── Pay Table (bottom of right column) ── */
.panel-paytable {
    background: linear-gradient(180deg, #1a1a3a 0%, #0e0e20 100%);
    border: 1px solid rgba(42, 42, 80, 0.5);
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}
.pt-header {
    padding: 6px 10px;
    background: rgba(0, 20, 60, 0.6);
    border-bottom: 1px solid rgba(42, 42, 80, 0.5);
    font-size: 11px;
    font-weight: 700;
    color: #5588aa;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
}
.pt-body {
    padding: 2px 0;
}
.pt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.15s;
}
.pt-row .pt-hand {
    color: #88aacc;
}
.pt-row .pt-pay {
    color: #5588aa;
    font-variant-numeric: tabular-nums;
}
.pt-row.active-rank {
    background: rgba(255, 215, 0, 0.05);
}
.pt-row.active-rank .pt-hand {
    color: #FFD700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}
.pt-row.active-rank .pt-pay {
    color: #FFD700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}
.pt-divider {
    height: 1px;
    background: rgba(42, 42, 80, 0.5);
    margin: 2px 10px;
}

/* ── Multi-Hand Grid (fixed height container) ── */
.multi-hand-wrap {
    height: 0;
    overflow: hidden;
    transition: height 0.15s ease;
    background: #0a0a12;
    flex-shrink: 0;
}
.multi-hand-wrap.open {
    height: 180px;
}
.multi-hand-wrap.open.large {
    height: 280px;
}
#multi-hand-grid {
    display: none;
    overflow-y: auto;
    padding: 4px 8px;
    height: 100%;
}
#multi-hand-grid.visible {
    display: grid;
    gap: 3px;
    align-content: start;
}
#multi-hand-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
#multi-hand-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
#multi-hand-grid.cols-10 { grid-template-columns: repeat(10, 1fr); }

.mini-hand {
    background: rgba(0, 10, 30, 0.5);
    border: 1px solid rgba(42, 42, 80, 0.5);
    border-radius: 3px;
    padding: 2px 3px;
    text-align: center;
    line-height: 1.2;
    min-height: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.mini-hand .mini-cards {
    display: flex;
    justify-content: center;
    gap: 1px;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
}
.mc {
    font-size: 9px;
    font-weight: 600;
    padding: 0 1px;
    border-radius: 2px;
    transition: background 0.1s;
}
.mc-red { color: #dd3333; }
.mc-black { color: #c0c8d8; }
.mc-held { background: rgba(255, 215, 0, 0.35); box-shadow: 0 1px 0 #aa8800; }
.mc-drawn { color: #00CC66 !important; }
.mc-facedown {
    background: linear-gradient(135deg, #1a2a6a 0%, #0e1a44 50%, #1a2a6a 100%);
    color: #1a2a6a !important;
    border: 1px solid #334488;
    border-radius: 2px;
    min-width: 16px;
    text-align: center;
}
.mini-hand .mini-result {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 8px;
    margin-top: 1px;
    height: 10px;
    color: #556688;
    letter-spacing: 0.3px;
}
.mini-hand.dealing { border-color: rgba(42, 42, 80, 0.5); opacity: 0.6; }
.mini-hand.dealing .mini-result { color: #5588aa; font-size: 7px; letter-spacing: 0.5px; }
.mini-hand.winner { opacity: 1; }
.mini-hand.winner .mini-result { font-weight: 700; }
.mini-hand.loser { opacity: 0.4; }

/* Per-hand-type colors (video poker machine style) */
.rank-color-RoyalFlush { color: #FFD700; }
.rank-color-StraightFlush { color: #FF8C00; }
.rank-color-FiveOfAKind { color: #ff44ff; }
.rank-color-FourAcesLowKick, .rank-color-FourAces { color: #FF4444; }
.rank-color-FourTwoThruFourLowKick, .rank-color-FourTwoThruFour { color: #ff6644; }
.rank-color-FourFiveThruK, .rank-color-FourOfAKind { color: #FF4444; }
.rank-color-FullHouse { color: #4488FF; }
.rank-color-Flush { color: #CC44CC; }
.rank-color-Straight { color: #FF6699; }
.rank-color-ThreeOfAKind { color: #44DD88; }
.rank-color-TwoPair { color: #44DDFF; }
.rank-color-JacksOrBetter { color: #8899AA; }

.rank-border-RoyalFlush { border-color: #FFD700; background: rgba(255,215,0,0.08); }
.rank-border-StraightFlush { border-color: #FF8C00; background: rgba(255,140,0,0.08); }
.rank-border-FiveOfAKind { border-color: #ff44ff; background: rgba(255,68,255,0.08); }
.rank-border-FourAcesLowKick, .rank-border-FourAces { border-color: #FF4444; background: rgba(255,68,68,0.08); }
.rank-border-FourTwoThruFourLowKick, .rank-border-FourTwoThruFour { border-color: #ff6644; background: rgba(255,100,68,0.08); }
.rank-border-FourFiveThruK, .rank-border-FourOfAKind { border-color: #FF4444; background: rgba(255,68,68,0.08); }
.rank-border-FullHouse { border-color: #4488FF; background: rgba(68,136,255,0.08); }
.rank-border-Flush { border-color: #CC44CC; background: rgba(204,68,204,0.08); }
.rank-border-Straight { border-color: #FF6699; background: rgba(255,102,153,0.08); }
.rank-border-ThreeOfAKind { border-color: #44DD88; background: rgba(68,221,136,0.08); }
.rank-border-TwoPair { border-color: #44DDFF; background: rgba(68,221,255,0.08); }
.rank-border-JacksOrBetter { border-color: #8899AA; background: rgba(136,153,170,0.08); }

/* Win summary flanking card area */
.card-area-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #0a0a12 0%, #0e0e20 100%);
    position: relative;
}
.win-summary-col {
    display: none;
    flex-direction: column;
    gap: 4px;
    position: absolute;
    top: 14px; /* align with top of cards */
    z-index: 10;
}
.win-summary-col.visible { display: flex; }
#win-summary-left { right: calc(50% + 340px); }
#win-summary-right { left: calc(50% + 340px); }
.win-summary-item {
    display: flex;
    align-items: stretch;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid;
    font-size: 13px;
    font-weight: 700;
}
.win-summary-count {
    padding: 2px 6px;
    min-width: 28px;
    text-align: center;
    color: #fff;
    font-size: 14px;
}
.win-summary-name {
    padding: 2px 8px;
    color: #fff;
    background: #111;
    flex: 1;
    font-size: 12px;
    display: flex;
    align-items: center;
}
.win-summary-pay-box {
    display: block;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    margin-top: -2px;
    border-radius: 2px;
}

/* Per-rank background colors for count box + border */
.ws-RoyalFlush { border-color: #FFD700; } .ws-RoyalFlush .win-summary-count { background: #FFD700; color: #000; }
.ws-RoyalFlush .win-summary-pay-box { background: #FFD700; color: #000; }
.ws-StraightFlush { border-color: #FF8C00; } .ws-StraightFlush .win-summary-count { background: #FF8C00; color: #000; }
.ws-StraightFlush .win-summary-pay-box { background: #FF8C00; color: #000; }
.ws-FiveOfAKind { border-color: #ff44ff; } .ws-FiveOfAKind .win-summary-count { background: #ff44ff; color: #000; }
.ws-FiveOfAKind .win-summary-pay-box { background: #ff44ff; color: #000; }
.ws-FourAcesLowKick, .ws-FourAces { border-color: #FF4444; } .ws-FourAcesLowKick .win-summary-count, .ws-FourAces .win-summary-count { background: #FF4444; }
.ws-FourAcesLowKick .win-summary-pay-box, .ws-FourAces .win-summary-pay-box { background: #FF4444; }
.ws-FourTwoThruFourLowKick, .ws-FourTwoThruFour { border-color: #ff6644; } .ws-FourTwoThruFourLowKick .win-summary-count, .ws-FourTwoThruFour .win-summary-count { background: #ff6644; color: #000; }
.ws-FourTwoThruFourLowKick .win-summary-pay-box, .ws-FourTwoThruFour .win-summary-pay-box { background: #ff6644; color: #000; }
.ws-FourFiveThruK, .ws-FourOfAKind { border-color: #FF4444; } .ws-FourFiveThruK .win-summary-count, .ws-FourOfAKind .win-summary-count { background: #FF4444; }
.ws-FourFiveThruK .win-summary-pay-box, .ws-FourOfAKind .win-summary-pay-box { background: #FF4444; }
.ws-FullHouse { border-color: #4488FF; } .ws-FullHouse .win-summary-count { background: #4488FF; }
.ws-FullHouse .win-summary-pay-box { background: #4488FF; }
.ws-Flush { border-color: #CC44CC; } .ws-Flush .win-summary-count { background: #CC44CC; }
.ws-Flush .win-summary-pay-box { background: #CC44CC; }
.ws-Straight { border-color: #FF6699; } .ws-Straight .win-summary-count { background: #FF6699; color: #000; }
.ws-Straight .win-summary-pay-box { background: #FF6699; color: #000; }
.ws-ThreeOfAKind { border-color: #44DD88; } .ws-ThreeOfAKind .win-summary-count { background: #44DD88; color: #000; }
.ws-ThreeOfAKind .win-summary-pay-box { background: #44DD88; color: #000; }
.ws-TwoPair { border-color: #44DDFF; } .ws-TwoPair .win-summary-count { background: #44DDFF; color: #000; }
.ws-TwoPair .win-summary-pay-box { background: #44DDFF; color: #000; }
.ws-JacksOrBetter { border-color: #8899AA; } .ws-JacksOrBetter .win-summary-count { background: #8899AA; color: #000; }
.ws-JacksOrBetter .win-summary-pay-box { background: #8899AA; color: #000; }

/* ── Below the Fold ── */
.below-fold {
    width: 100%;
    max-width: 1440px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Auto-Play Stats Panel (inside strategy panel) */
.autoplay-stats {
    display: none;
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.autoplay-stats.visible {
    display: flex;
    flex-direction: column;
}
.autoplay-stats.visible ~ .strat-scroll,
.panel-strategy:has(.autoplay-stats.visible) .strat-scroll {
    display: none;
}
.aps-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    margin-bottom: 10px;
}
.aps-stat { text-align: center; }
.aps-stat-label {
    font-size: 10px;
    color: #5588aa;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.aps-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #e0e0e0;
    margin-top: 1px;
}
.aps-stat-value.positive { color: #00dd44; }
.aps-stat-value.negative { color: #ff6655; }
.aps-dist-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.aps-distribution {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.aps-distribution th {
    color: #5588aa;
    font-size: 10px;
    text-transform: uppercase;
    padding: 3px 6px;
    text-align: left;
    border-bottom: 1px solid rgba(42, 42, 80, 0.5);
}
.aps-distribution td { padding: 2px 6px; color: #88aacc; }
.aps-distribution .expected { color: #556688; font-size: 10px; }
.aps-footer {
    padding-top: 6px;
    border-top: 1px solid rgba(42, 42, 80, 0.5);
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px;
}
.aps-progress { font-size: 12px; color: #88aacc; }
.aps-speed { font-size: 11px; color: #5588aa; }

/* Session History Panel */
.session-history {
    background: linear-gradient(180deg, #1a1a3a 0%, #0e0e20 100%);
    border: 2px solid rgba(42, 42, 80, 0.5);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 0 20px rgba(30, 30, 80, 0.3);
}
.sh-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(42, 42, 80, 0.5);
}
.sh-title {
    font-size: 14px;
    font-weight: 700;
    color: #44ddff;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.sh-clear {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    padding: 4px 10px;
    background: rgba(0,0,0,0.3);
    color: #5588aa;
    border: 1px solid #2a2a50;
    border-radius: 4px;
    cursor: pointer;
}
.sh-clear:hover { color: #ff6655; background: rgba(40,20,20,0.4); }
.sh-toggle {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    padding: 4px 10px;
    background: rgba(0,0,0,0.3);
    color: #5588aa;
    border: 1px solid #2a2a50;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 8px;
}
.sh-toggle:hover { color: #88aacc; background: rgba(40,40,80,0.4); }
.sh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.sh-table th {
    color: #5588aa;
    font-size: 11px;
    text-transform: uppercase;
    padding: 4px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(42, 42, 80, 0.5);
}
.sh-table td { padding: 4px 8px; color: #88aacc; }
.sh-table tr:hover td { background: rgba(50, 80, 150, 0.1); }
.sh-table .positive { color: #00dd44; }
.sh-table .negative { color: #ff6655; }
.sh-empty { color: #556688; font-size: 13px; text-align: center; padding: 16px; }

/* ── Analyzer expand (all viewports) ── */
.panel-game.analyze-active {
    overflow: visible;
}
.panel-game.analyze-active .mode-panel {
    overflow: visible;
}
.panel-game.analyze-active .analyze-panel {
    overflow: visible;
    flex: none;
}
.main-area:has(.panel-game.analyze-active) {
    height: auto;
    min-height: calc(100vh - 52px);
    min-height: calc(100dvh - 52px);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .main-area {
        grid-template-columns: 1fr;
        height: auto;
        min-height: calc(100vh - 52px);
        min-height: calc(100dvh - 52px); /* iOS/iPadOS Safari: dynamic viewport height */
        padding: 8px;
    }
    .right-column {
        height: auto;
    }
    .panel-strategy {
        max-height: none;
    }
    /* Collapsible pay table on mobile — collapsed by default */
    .panel-paytable .pt-header {
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .panel-paytable .pt-header::after {
        content: '\25BC';
        font-size: 9px;
        color: #5588aa;
        transition: transform 0.2s;
    }
    .panel-paytable.collapsed .pt-header::after {
        transform: rotate(-90deg);
    }
    .panel-paytable.collapsed .pt-body {
        display: none;
    }
}

@media (max-width: 700px) {
    .card {
        width: 64px;
        height: 90px;
    }
    .card-tl { top: 2px; left: 3px; }
    .card-br { bottom: 2px; right: 3px; }
    .card-corner-rank { font-size: 11px; }
    .card-corner-suit { font-size: 7px; margin-top: 0; }
    .card-center-suit { font-size: 48px; }
    .card-center-face .face-letter { font-size: 28px; }
    .card-center-face .face-suit { font-size: 16px; }
    .game-btn { font-size: 14px; padding: 8px 20px; }
    .game-picker-btn { font-size: 12px; padding: 4px 8px; gap: 4px; }
    .gpb-ev { font-size: 10px; }
    .gp-overlay { padding-top: 8px; }
    .gp-modal { max-height: calc(100dvh - 20px); border-radius: 10px; }
    .top-bar { padding: 6px 10px; }
    .bottom-row { flex-wrap: wrap; gap: 4px 8px; }
    .bottom-center { order: 1; width: 100%; justify-content: center; }
    .bottom-left { order: 2; font-size: 13px; gap: 8px; flex: 1; }
    .bottom-right { order: 3; font-size: 13px; }
    .credits-input-wrap, .no-bankrupt-label { display: none; }
}

/* ── Version Info ── */
.version-info {
    font-family: 'Inter', monospace, sans-serif;
    font-size: 11px;
    color: #556688;
    text-align: center;
    padding: 8px 16px 12px;
    letter-spacing: 0.5px;
}
.version-info .version-tag {
    color: #5588aa;
    font-weight: 600;
}
.version-info .version-date {
    color: #556688;
}

/* ── Hand Analyzer Panel ── */
.analyze-panel { display: none; padding: 16px; overflow-y: auto; flex: 1; min-height: 0; }
.analyze-panel.visible { display: block !important; }

.analyzer-input-row {
    display: flex; gap: 8px; align-items: center; margin-bottom: 12px;
}
.analyzer-input-row input[type="text"] {
    flex: 1; font-family: 'Inter', monospace; font-size: 16px;
    padding: 8px 12px; background: #0e0e20; color: #e0e0e0;
    border: 1px solid #2a2a50; border-radius: 4px; letter-spacing: 1px;
}
.analyzer-input-row input:focus { outline: none; border-color: #44ddff; }
.analyzer-btn {
    font-family: 'Inter', sans-serif; font-size: 13px; padding: 7px 14px;
    background: rgba(40,40,80,0.4); color: #88aacc; border: 1px solid #2a2a50;
    border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.analyzer-btn:hover { color: #44ddff; border-color: #44ddff; }

.analyzer-card-slots {
    display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.az-card-slot {
    width: 72px; height: 100px; border-radius: 6px; cursor: pointer;
    border: 2px dashed rgba(42, 42, 80, 0.5); background: #0e0e20; position: relative;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.15s;
}
.az-card-slot:hover { border-color: #44ddff; }
.az-card-slot.filled {
    border-style: solid; border-color: #555; background: #fff; cursor: pointer;
}
.az-card-slot.filled.black { color: #222; }
.az-card-slot.filled.red { color: #d40000; }
.az-card-slot .az-card-rank { font-size: 18px; font-weight: 800; font-family: Georgia, serif; }
.az-card-slot .az-card-suit { font-size: 14px; }
.az-card-slot .az-card-label {
    display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.az-card-slot .az-empty-label { color: #556688; font-size: 22px; }
.az-card-slot.split-card {
    width: 110px; border-color: #44ddff; background: #fffde8;
    flex-direction: row; gap: 0;
}
.az-card-slot.split-card .az-card-label { flex: 1; }
.az-card-slot .az-split-divider {
    font-size: 16px; font-weight: 700; color: #999; margin: 0 1px;
}
.az-card-slot .az-split-btn {
    position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
    font-size: 9px; font-weight: 700; line-height: 18px; text-align: center;
    background: #2a2a50; color: #44ddff; border: 1px solid #44ddff;
    border-radius: 3px; cursor: pointer; padding: 0;
}
.az-card-slot .az-split-btn:hover { background: #44ddff; color: #0e0e20; }
.split-variant-btn { min-width: 80px; }
.split-remove-btn { background: #442222 !important; color: #ff6666 !important; border-color: #ff6666 !important; }
.az-mini-card.split-mini { width: auto; min-width: 60px; padding: 0 4px; flex-direction: row; gap: 1px; }
.az-mini-card .mini-split-sep { font-size: 9px; color: #999; margin: 0 1px; }

.analyzer-picker {
    background: #0e0e20; border: 1px solid #2a2a50; border-radius: 6px;
    padding: 8px; margin-bottom: 12px;
}
.analyzer-picker-row {
    display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px;
}
.analyzer-picker-btn {
    font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 600;
    width: 32px; height: 32px; border-radius: 4px; border: 1px solid #2a2a50;
    background: rgba(20,20,50,0.6); color: #88aacc; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.analyzer-picker-btn:hover { background: rgba(68,221,255,0.15); color: #44ddff; border-color: #44ddff; }
.analyzer-picker-btn.disabled { opacity: 0.25; cursor: default; pointer-events: none; }
.analyzer-picker-btn.suit-heart, .analyzer-picker-btn.suit-diamond { color: #d40000; }
.analyzer-picker-btn.suit-club, .analyzer-picker-btn.suit-spade { color: #222; }
.analyzer-picker-label { font-size: 11px; color: #5588aa; text-align: center; margin-bottom: 4px; }

.analyzer-hint { font-size: 12px; color: #5588aa; min-height: 18px; margin-bottom: 12px; }
.analyzer-hint.error { color: #ff6655; }

/* ── Photo Scan Button + Modal ── */
.analyzer-btn.scan-btn { position: relative; overflow: hidden; }
.analyzer-btn.scan-btn input[type="file"] {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
.scan-status {
    display: none; align-items: center; gap: 8px; padding: 8px 12px;
    margin-bottom: 12px; border-radius: 6px; font-size: 13px;
    background: rgba(20,20,50,0.6); border: 1px solid #2a2a50;
}
.scan-status.visible { display: flex; }
.scan-status.loading { color: #44ddff; border-color: #44ddff; }
.scan-status.success { color: #00dd44; border-color: #00dd44; }
.scan-status.error { color: #ff6655; border-color: #ff6655; }
.scan-spinner {
    width: 14px; height: 14px; border: 2px solid transparent;
    border-top-color: #44ddff; border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scan-preview {
    display: none; margin-bottom: 12px; text-align: center;
}
.scan-preview.visible { display: block; }
.scan-preview img {
    max-width: 100%; max-height: 200px; border-radius: 6px;
    border: 1px solid #2a2a50;
}

.analyzer-game-selector { margin-bottom: 16px; }
.analyzer-game-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
    font-size: 12px; color: #5588aa; text-transform: uppercase; letter-spacing: 1px;
}
.analyzer-game-header button {
    font-family: 'Inter', sans-serif; font-size: 10px; padding: 2px 8px;
    background: rgba(0,0,0,0.3); color: #5588aa; border: 1px solid #2a2a50;
    border-radius: 4px; cursor: pointer;
}
.analyzer-game-header button:hover { color: #88aacc; background: rgba(40,40,80,0.4); }
.analyzer-game-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.az-game-chip {
    font-family: 'Inter', sans-serif; font-size: 12px; padding: 4px 10px;
    border-radius: 12px; border: 1px solid #2a2a50; cursor: pointer;
    background: transparent; color: #5588aa; transition: all 0.15s;
}
.az-game-chip:hover { color: #88aacc; border-color: rgba(42, 42, 80, 0.8); }
.az-game-chip.active { color: #44ddff; border-color: #44ddff; background: rgba(68,221,255,0.1); }
.az-game-chip.job { border-left: 3px solid #44aa88; }
.az-game-chip.ddb { border-left: 3px solid #aa8844; }
.az-game-chip.tdb { border-left: 3px solid #aa4488; }

/* Results */
.analyzer-results { }
.az-all-agree {
    background: rgba(0,40,20,0.4); border: 1px solid #2a6a3a; border-radius: 6px;
    padding: 10px 16px; color: #00dd44; font-size: 14px; margin-bottom: 12px;
}
.az-hold-group {
    background: rgba(10,10,30,0.6); border: 1px solid rgba(42, 42, 80, 0.5); border-radius: 6px;
    padding: 12px 16px; margin-bottom: 10px;
}
.az-hold-group-header {
    display: flex; align-items: center; gap: 12px; cursor: pointer; flex-wrap: wrap;
}
.az-hold-cards {
    display: flex; gap: 4px;
}
.az-mini-card {
    width: 36px; height: 50px; border-radius: 4px; font-size: 10px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    line-height: 1.1; border: 1px solid #aaa; background: #fff;
}
.az-mini-card.black { color: #222; }
.az-mini-card.red { color: #d40000; }
.az-mini-card.dimmed { opacity: 0.2; border-color: #555; }
.az-mini-card .mini-rank { font-weight: 800; font-family: Georgia, serif; font-size: 12px; }
.az-mini-card .mini-suit { font-size: 10px; }

.az-hold-desc { font-size: 14px; color: #88aacc; font-weight: 600; }
.az-severity-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 10px;
    text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.az-severity-negligible { background: rgba(100,100,120,0.3); color: #556688; }
.az-severity-minor { background: rgba(200,180,50,0.2); color: #ccaa33; }
.az-severity-significant { background: rgba(220,120,30,0.2); color: #dd8833; }
.az-severity-critical { background: rgba(220,50,50,0.2); color: #dd4444; }

.az-game-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.az-game-tag {
    font-size: 11px; padding: 2px 8px; border-radius: 8px;
    background: rgba(68,221,255,0.08); color: #88aacc; border: 1px solid #2a2a50;
}
.az-game-tag .tag-ev { color: #44ddff; font-weight: 600; margin-left: 4px; }
.az-game-tag.tied::after { content: ' (tied)'; color: #aa8844; font-size: 9px; }
.az-near-optimal-tags { margin-top: 4px; }
.az-near-optimal-label { font-size: 10px; color: #776622; margin-right: 4px; }
.az-game-tag.near-optimal { border-color: rgba(200,180,50,0.3); color: #998833; }

/* EV Matrix */
.az-ev-matrix { margin-top: 10px; display: none; }
.az-ev-matrix.open { display: block; }
.az-ev-table {
    width: 100%; border-collapse: collapse; font-size: 12px;
}
.az-ev-table th {
    text-align: left; padding: 4px 8px; color: #5588aa;
    border-bottom: 1px solid rgba(42, 42, 80, 0.5); font-weight: 600; font-size: 11px;
}
.az-ev-table td {
    padding: 4px 8px; border-bottom: 1px solid rgba(42, 42, 80, 0.5); color: #88aacc;
    font-family: monospace; font-size: 12px;
}
.az-ev-table td.ev-optimal { color: #00dd44; font-weight: 700; }
.az-ev-table td.ev-near-optimal { color: #ccaa33; }
.az-ev-table td.hold-label-cell { font-family: 'Inter', sans-serif; color: #88aacc; }
.az-ev-table tr:hover td { background: rgba(68,221,255,0.03); }
.az-expand-hint { font-size: 10px; color: #556688; margin-left: auto; }

@media (max-width: 700px) {
    .az-card-slot { width: 56px; height: 78px; }
    .az-card-slot.split-card { width: 90px; }
    .az-mini-card { width: 28px; height: 40px; }
    .az-mini-card .mini-rank { font-size: 10px; }
    .az-mini-card .mini-suit { font-size: 8px; }
}

/* ── Auth Gate Overlay ── */
.auth-gate {
    position: fixed; inset: 0; z-index: 9999;
    background: #0a0a12;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 20px;
    color: #e0e0e0;
    font-family: 'Inter', sans-serif;
}
.auth-gate h1 {
    font-size: 28px; font-weight: 700;
    letter-spacing: 2px; color: #44ddff;
}
.auth-gate p {
    font-size: 16px; color: #888;
    max-width: 400px; text-align: center; line-height: 1.5;
}
.auth-gate .auth-gate-spinner {
    width: 40px; height: 40px;
    border: 3px solid #333;
    border-top-color: #44ddff;
    border-radius: 50%;
    animation: auth-spin 0.8s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth-gate .auth-btn {
    font-family: 'Inter', sans-serif;
    font-size: 16px; padding: 10px 28px;
    background: #44ddff; color: #0a0a12;
    border: none; border-radius: 4px;
    cursor: pointer; font-weight: 600;
    letter-spacing: 1px;
}
.auth-gate .auth-btn:hover { background: #66eeff; }
.auth-gate.hidden { display: none; }

/* ── Reference Panel ── */
.reference-panel { display: none; padding: 16px; flex: 1; min-height: 0; }
.reference-panel.visible { display: block !important; }

.ref-controls {
    display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.ref-controls select {
    background: #1a1a2e; color: #e0e0e0; border: 1px solid #333;
    padding: 6px 10px; border-radius: 4px; font-size: 13px;
    font-family: 'Inter', sans-serif;
}
#ref-game-select { min-width: 260px; }
.ref-compare-label {
    color: #888; font-size: 13px; margin-left: 8px;
}
.ref-print-btn {
    background: #2a2a3e; color: #aaa; border: 1px solid #444;
    padding: 6px 14px; border-radius: 4px; cursor: pointer; font-size: 13px;
    font-family: 'Inter', sans-serif; margin-left: auto;
}
.ref-print-btn:hover { background: #3a3a4e; color: #ddd; }

.ref-content { display: flex; gap: 20px; align-items: flex-start; }
.ref-strategy-card { flex: 3; min-width: 0; }
.ref-diff-panel { flex: 2; min-width: 0; }

.ref-empty { color: #666; font-size: 14px; padding: 40px 0; text-align: center; }

/* Strategy Card */
.ref-card-header { margin-bottom: 12px; }
.ref-card-title { font-size: 18px; font-weight: 700; color: #44ddff; letter-spacing: 1px; }
.ref-card-meta { font-size: 12px; color: #888; margin-top: 2px; }

.ref-card-table { overflow-x: auto; }
.ref-card-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ref-card-table thead th {
    text-align: left; padding: 6px 8px; border-bottom: 2px solid #333;
    color: #888; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
}
.ref-col-rank { width: 36px; text-align: center; }
.ref-col-held { width: 44px; text-align: center; }
.ref-col-ev { width: 70px; text-align: right; }
.ref-col-freq { width: 66px; text-align: right; }

.ref-line {
    cursor: pointer; transition: background 0.15s;
}
.ref-line:hover { background: #1a1a2e; }
.ref-line td { padding: 5px 8px; border-bottom: 1px solid #1a1a2e; }
.ref-line .ref-col-rank { color: #666; text-align: center; }
.ref-line .ref-col-name { color: #e0e0e0; }
.ref-line .ref-col-held { color: #888; text-align: center; }
.ref-line .ref-col-ev { color: #aaa; text-align: right; font-variant-numeric: tabular-nums; }
.ref-line .ref-col-freq { color: #666; text-align: right; font-variant-numeric: tabular-nums; }

/* Color-code by cards held */
.ref-held-5 .ref-col-name { color: #44ddff; }
.ref-held-4 .ref-col-name { color: #66eebb; }
.ref-held-3 .ref-col-name { color: #ccdd66; }
.ref-held-2 .ref-col-name { color: #eebb66; }
.ref-held-1 .ref-col-name { color: #ee8866; }
.ref-held-0 .ref-col-name { color: #aa6666; }

.ref-line-detail td {
    padding: 4px 8px 8px 44px; color: #777; font-size: 12px;
    border-bottom: 1px solid #222;
}
.ref-line-detail span { margin-right: 16px; }

/* Diff Panel */
.ref-section { margin-bottom: 20px; }
.ref-section-title { font-size: 14px; font-weight: 700; color: #aaa; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.ref-ev-compare { font-size: 13px; color: #888; margin-bottom: 10px; }
.ref-diff-summary { font-size: 12px; color: #666; margin-bottom: 6px; }
.ref-mismatch-ev { font-size: 12px; color: #888; margin-bottom: 10px; padding: 5px 8px; background: #12121e; border-left: 2px solid #555; border-radius: 2px; }

.ref-pt-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 4px; }
.ref-pt-table th { text-align: left; padding: 4px 6px; border-bottom: 1px solid #333; color: #888; font-size: 11px; }
.ref-pt-table td { padding: 3px 6px; border-bottom: 1px solid #1a1a2e; font-variant-numeric: tabular-nums; }
.ref-pt-higher { color: #44dd88; }
.ref-pt-lower { color: #ee6655; }

.ref-diff-group { margin-bottom: 12px; }
.ref-diff-group-title { font-size: 12px; font-weight: 600; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.ref-diff-group-title.ref-new { color: #44dd88; }
.ref-diff-group-title.ref-removed { color: #ee6655; }
.ref-diff-group-title.ref-moved { color: #ddbb44; }

.ref-diff-line { font-size: 13px; color: #ccc; padding: 2px 0; }
.ref-diff-rank { color: #666; font-size: 11px; }
.ref-diff-badge { font-size: 11px; color: #888; background: #1a1a2e; padding: 1px 5px; border-radius: 3px; margin-left: 4px; }
.ref-diff-delta { font-weight: 700; min-width: 28px; display: inline-block; }
.ref-moved .ref-diff-delta { color: #ddbb44; }
.ref-diff-leap { font-size: 11px; color: #666; margin-left: 4px; }

/* Mobile: stack vertically */
@media (max-width: 900px) {
    .ref-content { flex-direction: column; }
    .ref-strategy-card, .ref-diff-panel { flex: none; width: 100%; }
    #ref-game-select { min-width: 180px; }
}

/* Print styles */
@media print {
    body { background: #fff !important; color: #000 !important; }
    .top-bar, .right-column, .game-content, .bottom-controls, .below-fold,
    .auth-gate, .gp-overlay, .ref-controls, .ref-diff-panel,
    .training-panel, .autoplay-panel, .analyze-panel,
    .training-warning-banner { display: none !important; }
    .main-area { display: block !important; grid-template-columns: 1fr !important; height: auto !important; min-height: 0 !important; }
    .panel-game { overflow: visible !important; }
    .reference-panel { display: block !important; padding: 0 !important; }
    .ref-card-title { color: #000 !important; font-size: 16pt; }
    .ref-card-meta { color: #444 !important; }
    .ref-card-table table { font-size: 10pt; }
    .ref-card-table thead th { color: #000 !important; border-bottom-color: #000 !important; }
    .ref-line td { border-bottom-color: #ccc !important; }
    .ref-line .ref-col-name, .ref-line .ref-col-ev, .ref-line .ref-col-freq,
    .ref-line .ref-col-held, .ref-line .ref-col-rank { color: #000 !important; }
    .ref-held-5 .ref-col-name, .ref-held-4 .ref-col-name, .ref-held-3 .ref-col-name,
    .ref-held-2 .ref-col-name, .ref-held-1 .ref-col-name, .ref-held-0 .ref-col-name { color: #000 !important; }
    .ref-line:hover { background: none !important; }
}
