:root {
    --felt: #1a472a;
    --felt-dark: #0d2b1a;
    --gold: #d4af37;
    --gold-bright: #f9e29c;
    --text-light: #f0f0f0;
    --shadow-card: 0 4px 12px rgba(0,0,0,0.5);
    --card-w: 90px;
    --card-h: 130px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    background-color: #050505;
    color: var(--text-light);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    height: 100vh;
}

#game-container {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, var(--felt) 0%, var(--felt-dark) 100%);
    display: flex;
    justify-content: center;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    max-width: 1366px;
    height: 100%;
    flex-direction: column;
    padding: 20px;
}

.screen.active { display: flex; }

/* Menu Screen */
.logo-area { text-align: center; margin-top: 10dvh; margin-bottom: 6dvh; }
.premium-title { font-size: clamp(2.2rem, 8vw, 4rem); color: var(--gold); text-transform: uppercase; letter-spacing: 4px; font-weight: 800; text-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.tagline { opacity: 0.65; font-style: italic; margin-top: 5px; font-size: 1rem; }

.main-menu { width: 300px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; z-index: 10; }
.menu-btn { padding: 14px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; text-transform: uppercase; transition: all 0.2s ease-in-out; }
.menu-btn.primary { background: var(--gold); color: #000; }
.menu-btn.secondary { background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.menu-btn.outline { background: transparent; color: var(--gold); border: 1px solid var(--gold); font-size: 0.8rem; }
.menu-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.4); filter: brightness(1.1); }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.footer-disclaimer { position: absolute; bottom: 20px; width: 100%; text-align: center; font-size: 0.75rem; opacity: 0.5; left: 0; pointer-events: none; }

/* Table Screen / HUD */
.hud { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; width: 100%; z-index: 20; }
.balance-pill { background: rgba(0,0,0,0.45); padding: 6px 16px; border-radius: 20px; border: 1px solid var(--gold); text-align: right; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.currency-label { font-size: 0.65rem; color: var(--gold); display: block; text-transform: uppercase; letter-spacing: 0.5px; }
#balance-val { font-size: 1.25rem; font-weight: bold; color: #fff; }

.exit-btn { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.3); color: white; padding: 6px 14px; border-radius: 4px; cursor: pointer; font-weight: 600; transition: 0.2s; }
.exit-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.5); }

.table { flex-grow: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 15px; padding-top: 15px; overflow: hidden; width: 100%; }

.deck-pile { position: absolute; right: 20px; top: 15px; width: var(--card-w); height: var(--card-h); background: #0d2e1a; border-radius: 6px; border: 2px solid var(--gold); opacity: 0.25; pointer-events: none; }

.card-slot { width: var(--card-w); height: var(--card-h); border: 2px dashed rgba(212, 175, 55, 0.35); border-radius: 6px; display: flex; align-items: center; justify-content: center; position: relative; }
.card-slot.large-slot { width: 105px; height: 148px; cursor: pointer; background: rgba(0,0,0,0.15); transition: background 0.2s; }
.card-slot.large-slot:hover { background: rgba(0,0,0,0.25); }

#tap-prompt { font-size: 0.75rem; color: var(--gold); text-align: center; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; animation: pulse 1.5s infinite; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }

/* Target Indicator for Charm / Jinx */
.target-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
    padding: 6px 14px;
    background: rgba(0,0,0,0.65);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    animation: pulse-slow 2.5s infinite;
    min-width: 110px;
}
.indicator-label {
    font-size: 10px;
    color: var(--gold);
    text-transform: uppercase;
    tracking-wider: 1px;
    font-weight: bold;
    opacity: 0.8;
    line-height: 1.1;
}
.indicator-value {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
    margin-top: 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.deal-area { display: flex; width: 100%; justify-content: space-around; max-width: 900px; height: 50vh; margin-top: 5px; }
.side-container { width: 45%; display: flex; flex-direction: column; align-items: center; position: relative; height: 100%; }
.side-label { font-weight: 800; letter-spacing: 2px; color: rgba(255,255,255,0.3); margin-bottom: 8px; font-size: 0.85rem; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.stack { position: relative; width: 100%; height: calc(100% - 30px); }

/* Cards Styling & Animations (Priority 1 & 3) */
.card {
    width: var(--card-w);
    height: var(--card-h);
    position: absolute;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), top 0.3s ease, left 0.3s ease;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: var(--shadow-card);
}
.card.flipped { transform: translateX(-50%) rotateY(180deg); }
.card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; border-radius: 6px; border: 1px solid rgba(0,0,0,0.15); }

.card-back { background: #0d2e1a; border: 3px solid var(--gold); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.card-back::after { content: 'V'; color: var(--gold); font-size: 2rem; font-weight: bold; border: 1px solid var(--gold); width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center; opacity: 0.5; }

.card-front { background: white; color: black; transform: rotateY(180deg); display: flex; flex-direction: column; justify-content: space-between; padding: 6px; box-shadow: inset 0 0 8px rgba(0,0,0,0.05); }

/* Class colors (Priority 1) */
.card.red .card-front { color: #d63031 !important; }
.card.black .card-front { color: #2d3436 !important; }

.suit-main { font-size: 2.2rem; align-self: center; line-height: 1; }
.rank-top { font-weight: bold; font-size: 1rem; line-height: 1; }

/* Control Panels & Selectors */
.controls-panel { background: rgba(0,0,0,0.8); backdrop-filter: blur(10px); border-top: 1.5px solid var(--gold); padding: 15px; position: fixed; bottom: 0; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 50; }
.panel-label { font-size: 0.75rem; color: var(--gold); text-transform: uppercase; font-weight: bold; tracking-wider: 0.5px; }
.chip-row { display: flex; gap: 8px; margin: 4px 0; }
.chip { width: 44px; height: 44px; border-radius: 50%; background: transparent; border: 2px solid var(--gold); color: var(--gold); font-weight: bold; cursor: pointer; transition: 0.2s; }
.chip.active { background: var(--gold); color: black; transform: scale(1.15); box-shadow: 0 0 12px rgba(212,175,55,0.6); }

.action-row { display: flex; gap: 15px; width: 100%; max-width: 500px; margin-top: 4px; }
.predict-btn { flex: 1; padding: 12px; border-radius: 25px; border: none; font-weight: bold; cursor: pointer; text-transform: uppercase; background: #fff; color: #000; font-size: 0.9rem; transition: all 0.2s; }
.predict-btn:hover { opacity: 0.95; transform: scale(1.02); }
#btn-predict-andar { border-left: 6px solid #3498db; }
#btn-predict-bahar { border-left: 6px solid #e67e22; }

.selection-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.select-row { display: flex; gap: 10px; margin-top: 2px; }
.target-preview { font-weight: bold; color: var(--gold-bright); margin-top: 3px; font-size: 0.85rem; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }

/* Modals & Overlays (Priority 4) */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.result-content, .modal-card { background: #111; border: 1.5px solid var(--gold); padding: 30px; border-radius: 16px; text-align: center; width: 90%; max-width: 400px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); }
#result-icon { font-size: 3.5rem; margin-bottom: 10px; }
#result-status { font-size: 2.2rem; color: var(--gold); font-weight: 800; text-transform: uppercase; letter-spacing: 2px; }
.result-payout { font-size: 1.8rem; font-weight: 800; margin: 15px 0; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.result-stats { margin-bottom: 20px; font-size: 1rem; color: #ccc; }
.result-actions { display: flex; flex-direction: column; gap: 10px; }

.help-scroll { text-align: left; max-height: 200px; overflow-y: auto; margin: 15px 0; padding-right: 8px; }
.help-scroll p { margin-bottom: 12px; font-size: 0.9rem; line-height: 1.4; color: #ddd; }
.help-scroll p strong { color: var(--gold); }

#stats-grid { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; text-align: left; }
#stats-grid p { border-bottom: 1px solid rgba(212,175,55,0.15); padding-bottom: 6px; font-size: 1rem; display: flex; justify-content: space-between; }

/* Audio Floating Button */
#sound-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0,0,0,0.65);
    border: 1px solid var(--gold);
    color: var(--gold);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    z-index: 60;
}
#sound-btn:hover {
    transform: scale(1.1);
    background: rgba(0,0,0,0.85);
}

.hidden { display: none !important; }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes pulse-slow { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02); } }

/* Select boxes */
select {
    background: #222;
    color: white;
    border: 1.5px solid var(--gold);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    font-weight: 600;
}
select:focus {
    box-shadow: 0 0 8px rgba(212,175,55,0.4);
}

/* Scrollbars */
.help-scroll::-webkit-scrollbar { width: 6px; }
.help-scroll::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 3px; }
.help-scroll::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

/* Desktop Scaling */
@media (min-width: 1024px) {
    :root {
        --card-w: 105px;
        --card-h: 150px;
    }
    .card-slot.large-slot { width: 120px; height: 174px; }
    .table { gap: 20px; padding-top: 25px; }
    .deal-area { height: 55vh; max-width: 1000px; }
}
