/* =============================================================
   BLITZ 31 - CASINO MODALS & FULL-SCREEN 52-CARD DRAW ENGINE
   ============================================================= */

/* 1. VISIBILITY PROTECTION (Prevents unprompted modal overlays) */
.modal-backdrop[style*="display: none"],
.modal-backdrop[style*="display:none"],
.modal-overlay[style*="display: none"],
.modal-overlay[style*="display:none"],
[style*="display: none"],
[style*="display:none"] {
    display: none !important;
}

/* 2. BASE POPUP DIALOGS & OVERLAYS */
.modal-backdrop,
.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 12px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-sizing: border-box;
}

.modal-box,
.modal-card {
    background: rgba(6, 28, 17, 0.98);
    border: 2px solid var(--accent-gold, #d4af37);
    border-radius: 12px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.85), inset 0 0 15px rgba(0, 0, 0, 0.5);
    color: #f1f5f9;
    padding: 18px 16px;
    box-sizing: border-box;
    width: 100%;
    max-width: 420px;
    max-height: 88vh;
    overflow-y: auto;
}

.modal-box.wide,
.modal-card.wide,
.full-pool-card,
.ledger-modal-card {
    max-width: 540px;
}

.modal-header,
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 8px;
}

.modal-header h3,
.modal-box h3,
.modal-card h2,
.modal-card h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--accent-gold, #d4af37);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.modal-box .subtitle,
.modal-card p.subtitle,
#dealer-draw-desc,
#pool-modal-instruction,
#tie-breaker-stream-msg {
    font-size: 0.72rem;
    color: #94a3b8;
    margin: 1px 0 4px 0;
    font-weight: 600;
    text-align: center;
}

.close-x-btn,
.close-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 1.25rem;
    font-weight: 800;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
}

/* =============================================================
   3. FULL-SCREEN DEALER CUT MODAL (3 ROWS OF 2 PLAYERS + 11x5 CARDS)
   ============================================================= */
.modal-backdrop.fullscreen-modal,
.modal-overlay.fullscreen-modal,
#dealer-draw-modal,
#pool-draw-modal,
#tie-breaker-reveal-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
    background: radial-gradient(circle at 50% 25%, #0e3d26 0%, #061c11 75%, #020a06 100%) !important;
    z-index: 9999 !important;
    justify-content: center !important;
    align-items: center !important;
}

.fullscreen-modal .modal-box,
.fullscreen-modal .modal-card,
#dealer-draw-modal .modal-card,
#pool-draw-modal .modal-box,
#tie-breaker-reveal-modal .modal-box {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    padding: max(8px, env(safe-area-inset-top, 8px)) 6px max(8px, env(safe-area-inset-bottom, 8px)) 6px !important;
}

#dealer-draw-title,
#pool-modal-title {
    font-size: 1.1rem !important;
    font-weight: 900 !important;
    color: var(--accent-gold, #d4af37) !important;
    text-align: center !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    margin: 0 0 2px 0 !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8) !important;
}

/* OUTER MODAL CONTAINER */
#pool-cards-container,
.draw-modal-split-layout {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    max-width: 480px !important;
    flex: 1 !important;
    min-height: 0 !important;
    gap: 3px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

/* -------------------------------------------------------------
   PLAYER SHOWCASE: 3 ROWS IN SETS OF 2 (ENLARGED & READABLE)
   ------------------------------------------------------------- */
.draw-showcase-sidebar,
.results-stream,
#draw-results-stream,
#pool-cards-container > :first-child:not(.draw-pool-panel):not(.pool-52-grid) {
    width: 100% !important;
    max-width: 420px !important;
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important; /* Sets of 2 */
    grid-auto-rows: auto !important; /* 3 rows for up to 6 players */
    gap: 4px 10px !important;
    justify-items: center !important;
    align-items: center !important;
    border: none !important;
    border-bottom: 1.5px solid rgba(212, 175, 55, 0.3) !important;
    padding: 2px 6px 6px 6px !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    max-height: 235px !important;
    overflow-y: auto !important;
}

/* Suppress stray label elements inside grid */
.draw-showcase-sidebar > *:not(.draw-showcase-item):not(.result-item),
.results-stream > *:not(.draw-showcase-item):not(.result-item),
#draw-results-stream > *:not(.draw-showcase-item):not(.result-item),
#pool-cards-container > :first-child:not(.draw-pool-panel):not(.pool-52-grid) > *:not(.draw-showcase-item):not(.result-item) {
    display: none !important;
}

/* Enlarged Player Pod */
.draw-showcase-item,
.result-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    background: rgba(4, 20, 13, 0.95) !important;
    border: 1.5px solid rgba(212, 175, 55, 0.55) !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6) !important;
    width: 100% !important;
    max-width: 175px !important;
    box-sizing: border-box !important;
}

.draw-picker-badge {
    font-size: 0.74rem !important;
    font-weight: 800 !important;
    color: #f6e05e !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 155px !important;
    text-align: center !important;
}

.draw-card-waiting {
    width: 38px !important;
    height: 52px !important;
    border: 1.5px dashed #64748b !important;
    border-radius: 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.6rem !important;
    font-weight: 700 !important;
    color: #94a3b8 !important;
    background: rgba(0, 0, 0, 0.35) !important;
}

/* Enlarged Playing Card in Player Pod */
.draw-showcase-item .playing-card {
    width: 38px !important;
    height: 52px !important;
    padding: 2px 3px !important;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.7) !important;
    border-radius: 4px !important;
    box-sizing: border-box !important;
}

.draw-showcase-item .playing-card .corner-val {
    font-size: 0.72rem !important;
    font-weight: 900 !important;
    line-height: 1 !important;
}

.draw-showcase-item .playing-card .corner-suit {
    font-size: 0.6rem !important;
    line-height: 1 !important;
}

.draw-showcase-item .playing-card .card-center-pip {
    font-size: 1.05rem !important;
    line-height: 1 !important;
}

/* POOL LABELS */
.draw-pool-panel {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    padding-top: 1px !important;
}

.draw-pool-panel > span,
.draw-pool-panel > p,
#pool-cards-container > span {
    font-size: 0.66rem !important;
    color: #94a3b8 !important;
    font-weight: 700 !important;
    margin: 1px 4px !important;
    display: inline-block !important;
    text-align: center !important;
}

/* -------------------------------------------------------------
   4. TIGHTENED 52-CARD GRID: 11 COLUMNS x 5 ROWS
   ------------------------------------------------------------- */
#draw-pool-grid,
.card-pool-grid,
.pool-52-grid,
.draw-pool-panel > div:last-child {
    display: grid !important;
    grid-template-columns: repeat(11, 1fr) !important;
    grid-template-rows: repeat(5, auto) !important;
    gap: 2px 2px !important; /* Tight gaps between rows and cards */
    width: 100% !important;
    max-width: 460px !important;
    margin: 2px auto 0 auto !important;
    padding: 1px !important;
    box-sizing: border-box !important;
    justify-items: center !important;
    align-content: start !important;
}

/* Individual 52 Cards */
.card-pool-item,
.pool-card-item {
    width: 100% !important;
    height: clamp(30px, 4.2vh, 38px) !important;
    max-height: 38px !important;
    min-height: 30px !important;
    aspect-ratio: 2 / 2.7 !important;
    background: linear-gradient(135deg, #1d4ed8 0%, #0f172a 100%) !important;
    border: 1.5px solid #93c5fd !important;
    border-radius: 3px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    font-weight: 900 !important;
    font-size: 0.72rem !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6) !important;
    transition: transform 0.12s ease, border-color 0.12s ease !important;
}

.card-pool-item:hover,
.pool-card-item:hover,
.card-pool-item:active,
.pool-card-item:active {
    transform: scale(1.15) !important;
    border-color: #f6e05e !important;
    box-shadow: 0 0 10px rgba(246, 224, 94, 0.8) !important;
    z-index: 25 !important;
}

.card-pool-item.taken,
.pool-card-item.taken {
    background: #04140b !important;
    border: 1px solid #143521 !important;
    color: #10b981 !important;
    cursor: not-allowed !important;
    opacity: 0.22 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* TIE-BREAKER RESOLUTION STREAM */
#tie-breaker-stream-grid {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    max-height: 50vh !important;
    overflow: hidden !important;
    margin-top: 6px !important;
}

/* 5. ACTIVE BETS & LEDGER MODALS */
.bets-content,
.settings-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bets-section h4,
#ledger-tables-wrapper h4 {
    margin: 0 0 8px 0;
    color: var(--accent-gold-bright, #f6e05e);
    font-size: 0.88rem;
    font-weight: 800;
    text-transform: uppercase;
}

.bet-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.bet-input-row select,
.setting-item select {
    flex: 1;
    background: #04160e;
    border: 1px solid rgba(212, 175, 55, 0.5);
    color: #ffffff;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.82rem;
    font-weight: 700;
    outline: none;
}

#ledger-tables-wrapper {
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 4px;
}

.ledger-actions-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

/* 6. CHAT WINDOW & GLOBAL SIDE BETS DRAWERS */
#chat-window,
#chat-drawer,
.chat-drawer,
#global-side-bets-sidebar,
.global-bets-drawer {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 320px;
    max-width: 90vw;
    height: 250px;
    background: rgba(4, 20, 13, 0.96);
    border: 1.5px solid rgba(212, 175, 55, 0.45);
    border-top-left-radius: 12px;
    display: flex;
    flex-direction: column;
    z-index: 500;
    box-shadow: 0 -6px 22px rgba(0, 0, 0, 0.75);
    box-sizing: border-box;
}

.drawer-header {
    background: rgba(14, 46, 29, 0.95);
    padding: 7px 12px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    border-top-left-radius: 10px;
    margin-bottom: 0;
}

.drawer-header h4 {
    margin: 0;
    font-size: 0.82rem;
    color: var(--accent-gold, #d4af37);
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.drawer-body,
.chat-messages,
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.78rem;
}

.drawer-footer,
.chat-input-bar {
    display: flex;
    padding: 6px;
    gap: 6px;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    background: rgba(2, 10, 6, 0.85);
}

.drawer-footer input,
.chat-input-bar input {
    flex: 1;
    background: #020a06;
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 4px;
    color: #fff;
    padding: 6px 8px;
    font-size: 0.78rem;
    outline: none;
}

.drawer-footer button,
.chat-input-bar button {
    background: linear-gradient(180deg, #d4af37 0%, #aa820a 100%);
    color: #04190e;
    font-weight: 800;
    border: none;
    border-radius: 4px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 0.78rem;
}

/* 7. KNOCK & CELEBRATION OVERLAYS */
#knock-alert-modal,
.knock-pulse-overlay,
.knock-banner {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(220, 38, 38, 0.95);
    color: #ffffff;
    border: 2px solid #fecaca;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 1.15rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 30px rgba(220, 38, 38, 0.8);
    z-index: 10000;
    pointer-events: none;
    text-align: center;
    animation: pulseKnock 1s infinite alternate ease-in-out;
}

@keyframes pulseKnock {
    from { transform: translate(-50%, -50%) scale(1); }
    to { transform: translate(-50%, -50%) scale(1.06); }
}

#celebration-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99999;
}
/* While the dealer-draw or tie-breaker screen is open, keep the status banner and other pop-up
   notices off the picked cards: park them at the bottom of the screen instead of over the middle. */
body:has(#dealer-draw-modal[style*="flex"]) #center-notification-banner,
body:has(#tie-breaker-reveal-modal[style*="flex"]) #center-notification-banner {
    top: auto !important;
    bottom: calc(18px + env(safe-area-inset-bottom)) !important;
    z-index: 10001 !important;
}
body:has(#dealer-draw-modal[style*="flex"]) #knock-alert-modal,
body:has(#tie-breaker-reveal-modal[style*="flex"]) #knock-alert-modal,
body:has(#dealer-draw-modal[style*="flex"]) #invite-toast,
body:has(#tie-breaker-reveal-modal[style*="flex"]) #invite-toast {
    top: auto !important;
    bottom: calc(70px + env(safe-area-inset-bottom)) !important;
}
