:root {
    --bg-main: #0a0a0a;
    --table-felt: #0d5a2e;
    --gold: #ffd700;
    --player-blue: #2c7fb8;
    --banker-red: #d32f2f;
    --tie-green: #2ecc71;
}

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

body {
    background: var(--bg-main);
    font-family: 'Kanit', sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ===== MONITOR TOP ===== */
.monitor-section {
    flex: 0 0 50%;
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1e 100%);
    position: relative;
    border-bottom: 3px solid var(--gold);
    overflow: hidden;
    box-shadow: inset 0 -20px 40px rgba(0,0,0,0.8);
}

.virtual-studio {
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at center, #2c3e50 0%, #000 70%);
    position: relative;
    display: flex; justify-content: center; align-items: center;
}

.studio-logo {
    position: absolute; top: 15%;
    font-size: 5rem; font-weight: 900; color: rgba(255, 255, 255, 0.02);
    font-family: 'Orbitron'; letter-spacing: 15px;
    text-shadow: 0 0 50px rgba(255, 215, 0, 0.1);
}

/* Card Shoe */
.card-shoe {
    position: absolute; top: 15%; left: 50%; transform: translateX(-50%);
    width: 180px; height: 80px;
    background: linear-gradient(145deg, #2c2c2c, #1a1a1a);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.9), inset 0 2px 5px rgba(255,255,255,0.1);
    z-index: 10;
}
.shoe-slot {
    position: absolute; top: 20px; left: 20px; width: 140px; height: 35px;
    background: #000; border-radius: 4px; overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.9);
}
.deck-visual {
    width: 100%; height: 100%;
    background: repeating-linear-gradient(90deg, #fff 0px, #fff 2px, #e0e0e0 2px, #e0e0e0 4px);
    opacity: 0.6;
}
.shoe-label {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    color: var(--gold); font-size: 0.7rem; font-family: 'Orbitron'; letter-spacing: 2px;
}

/* System Info Overlay */
.system-overlay {
    position: absolute; top: 15px; left: 15px; right: 15px;
    display: flex; justify-content: space-between;
    color: rgba(255,255,255,0.7); font-size: 0.85rem; z-index: 5;
}
.table-id {
    background: rgba(0,0,0,0.6); padding: 5px 12px;
    border-radius: 20px; border: 1px solid rgba(255,215,0,0.3);
}
.network-stat {
    background: rgba(0,0,0,0.6); padding: 5px 12px; border-radius: 20px;
}

/* Timer Circle */
.timer-overlay {
    position: absolute; top: 25px; right: 25px;
    width: 90px; height: 90px; z-index: 10;
}
.timer-overlay svg { transform: rotate(-90deg); }
.timer-text {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 2.8rem; font-family: 'Orbitron'; font-weight: 900;
    color: #4cd137; text-shadow: 0 0 20px #4cd137;
}
.timer-text.warning {
    color: #ff3838; text-shadow: 0 0 20px #ff3838; animation: pulse 0.5s infinite;
}
@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* Cards Playing Area - ปรับใหม่รองรับ 3 ใบ */
.cards-area {
    position: absolute; bottom: 15%; width: 100%;
    display: flex; justify-content: center; gap: 150px; z-index: 20;
}
.hand-container {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.hand-label {
    font-size: 1.2rem; font-weight: 700;
    color: rgba(255,255,255,0.9); text-shadow: 0 2px 10px rgba(0,0,0,0.8);
    font-family: 'Orbitron'; letter-spacing: 2px;
}
.hand-label.player { color: var(--player-blue); text-shadow: 0 0 10px var(--player-blue); }
.hand-label.banker { color: var(--banker-red); text-shadow: 0 0 10px var(--banker-red); }

.hand-cards {
    display: flex;
    justify-content: center;
    /* ปรับให้กว้างขึ้นรองรับไพ่ 3 ใบ */
    min-width: 120px; 
    min-height: 100px;
    position: relative;
}

.card {
    width: 70px; height: auto; border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.9);
    animation: cardDeal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    transition: transform 0.3s;
}

/* ทำให้ไพ่ซ้อนกันแบบพัด */
.card:not(:first-child) {
    margin-left: -40px; /* ซ้อนทับใบก่อนหน้า */
}

/* ใบที่ 3 หมุนนิดหน่อย */
.card:nth-child(3) {
    transform: translateY(-5px) rotate(5deg);
    z-index: 5;
}

@keyframes cardDeal {
    0% { transform: translateY(-200px) translateX(0) rotate(-15deg) scale(0.3); opacity: 0; }
    100% { transform: translateY(0) translateX(0) rotate(0) scale(1); opacity: 1; }
}

.score-badge {
    font-size: 2.5rem; font-family: 'Orbitron'; font-weight: 900;
    color: #fff; background: rgba(0,0,0,0.8);
    width: 60px; height: 60px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 20px rgba(255,215,0,0.5); border: 3px solid var(--gold);
    opacity: 0; animation: scoreAppear 0.5s forwards;
}
@keyframes scoreAppear { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }

/* Win Banner */
.win-banner {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0);
    font-size: 4.5rem; font-family: 'Orbitron'; font-weight: 900;
    padding: 20px 80px; border-radius: 15px; border: 5px solid;
    background: rgba(0,0,0,0.95); z-index: 100; opacity: 0;
    backdrop-filter: blur(10px);
}
.win-banner.show { animation: bannerPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
@keyframes bannerPop {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
}
.win-banner.player { color: var(--player-blue); border-color: var(--player-blue); text-shadow: 0 0 30px var(--player-blue); }
.win-banner.banker { color: var(--banker-red); border-color: var(--banker-red); text-shadow: 0 0 30px var(--banker-red); }
.win-banner.tie { color: var(--tie-green); border-color: var(--tie-green); text-shadow: 0 0 30px var(--tie-green); }

/* Particles */
.particle {
    position: absolute; width: 8px; height: 8px; border-radius: 50%;
    pointer-events: none; z-index: 999; animation: particleFly 2s ease-out forwards;
}
@keyframes particleFly {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
}

/* ===== CONTROL PANEL BOTTOM ===== */
.control-panel { flex: 1; background: #1a1a1a; display: flex; flex-direction: column; }

/* User Bar */
.user-bar {
    height: 45px; background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px; border-bottom: 2px solid #333;
}
.user-badge {
    background: linear-gradient(135deg, #333, #1a1a1a); color: var(--gold);
    padding: 5px 15px; border-radius: 20px; font-weight: 700;
    font-size: 0.9rem; border: 1px solid var(--gold);
}
.balance-display {
    color: #fff; font-size: 1.3rem; font-family: 'Orbitron'; font-weight: 700; margin-left: 15px;
}
.balance-display span { color: var(--gold); }
.game-info { display: flex; gap: 10px; align-items: center; }
.status-live {
    background: linear-gradient(135deg, #e74c3c, #c0392b); color: #fff;
    padding: 4px 12px; border-radius: 20px; font-size: 0.75rem;
    font-weight: 700; animation: livePulse 2s infinite;
}
@keyframes livePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    50% { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0); }
}

/* Betting Table */
.betting-table {
    flex: 1; background: linear-gradient(135deg, var(--table-felt) 0%, #0a4020 100%);
    display: flex; flex-direction: column; padding: 8px; gap: 8px;
    box-shadow: inset 0 0 60px rgba(0,0,0,0.7); position: relative;
}
.betting-table::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 20px, rgba(255,255,255,0.01) 20px, rgba(255,255,255,0.01) 21px),
                repeating-linear-gradient(90deg, transparent, transparent 20px, rgba(255,255,255,0.01) 20px, rgba(255,255,255,0.01) 21px);
    pointer-events: none;
}
.bet-row { display: flex; gap: 8px; }
.bet-row.pairs { flex: 0 0 35%; }
.bet-row.main { flex: 1; }

.bet-zone {
    flex: 1; border-radius: 12px; position: relative; cursor: pointer;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    color: #fff; font-weight: 700; transition: all 0.2s;
    border: 2px solid rgba(255,255,255,0.1); overflow: hidden;
}
.bet-zone::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.1) 0%, transparent 70%);
    opacity: 0; transition: opacity 0.3s;
}
.bet-zone:hover::before { opacity: 1; }
.bet-zone:active { transform: scale(0.95); }

.bet-zone.pair { background: linear-gradient(135deg, rgba(0,0,0,0.4), rgba(0,0,0,0.6)); border-color: rgba(255,255,255,0.2); }
.bet-zone.tie { background: linear-gradient(135deg, #16a085, #0e6251); border-color: var(--tie-green); flex: 1.3; }
.bet-zone.player { background: linear-gradient(135deg, rgba(44, 127, 184, 0.3), rgba(28, 97, 154, 0.5)); border: 3px solid var(--player-blue); }
.bet-zone.banker { background: linear-gradient(135deg, rgba(211, 47, 47, 0.3), rgba(161, 37, 37, 0.5)); border: 3px solid var(--banker-red); }

.zone-title { font-size: 1.8rem; font-family: 'Orbitron'; text-shadow: 0 2px 10px rgba(0,0,0,0.8); }
.zone-odds { font-size: 0.85rem; opacity: 0.8; margin-top: 5px; }

.bet-amount {
    position: absolute; top: 10px; right: 10px;
    background: rgba(0,0,0,0.8); color: var(--gold);
    padding: 3px 10px; border-radius: 15px; font-size: 0.9rem;
    font-family: 'Orbitron'; font-weight: 700; display: none;
}
.bet-amount.active { display: block; animation: betPulse 0.3s; }
@keyframes betPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }

/* Chip Stack on Table (Fix) */
.chip-stack {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none; z-index: 50;
}
.chip-on-table {
    position: absolute; width: 40px; height: 40px; border-radius: 50%;
    border: 2px dashed #fff; box-shadow: 0 3px 5px rgba(0,0,0,0.8);
    display: flex; justify-content: center; align-items: center;
    font-size: 10px; font-weight: bold; color: #000;
    font-family: 'Orbitron', sans-serif;
    top: 50%; left: 50%; margin-top: -20px; margin-left: -20px;
    transition: transform 0.2s;
}

/* Footer UI */
.footer-ui { height: 140px; background: #f5f5f5; display: flex; border-top: 2px solid #ddd; }
.roadmap-section { flex: 1; background: #fff; padding: 5px; border-right: 2px solid #ddd; overflow: hidden; }
.roadmap-title { font-size: 0.8rem; font-weight: 700; color: #666; margin-bottom: 3px; text-align: center; }
.roadmap-grid { display: grid; grid-template-rows: repeat(6, 1fr); grid-auto-flow: column; gap: 2px; height: calc(100% - 25px); }
.road-cell { background: #f9f9f9; border: 1px solid #e0e0e0; border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.road-dot { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.road-dot.P { background: var(--player-blue); }
.road-dot.B { background: var(--banker-red); }
.road-dot.T { background: var(--tie-green); }

.chips-section {
    flex: 0 0 160px; background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; border-right: 2px solid #ddd; padding: 10px;
}
.chip-selector { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
    width: 45px; height: 45px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Orbitron'; font-weight: 700; font-size: 0.85rem;
    cursor: pointer; transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); border: 3px dashed rgba(255,255,255,0.5);
}
.chip:hover { transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,0.4); }
.chip.selected { transform: translateY(-8px) scale(1.1); box-shadow: 0 8px 20px rgba(0,0,0,0.5); border-color: #000; border-style: solid; }
.chip.c100 { background: linear-gradient(135deg, #fff, #e0e0e0); color: #333; }
.chip.c500 { background: linear-gradient(135deg, #e74c3c, #c0392b); color: #fff; }
.chip.c1k { background: linear-gradient(135deg, #3498db, #2980b9); color: #fff; }
.chip.c5k { background: linear-gradient(135deg, #f39c12, #e67e22); color: #000; }
.confirm-btn {
    background: linear-gradient(135deg, #27ae60, #229954); color: #fff; border: none;
    padding: 10px 20px; border-radius: 25px; font-weight: 700; cursor: pointer;
    font-size: 0.95rem; box-shadow: 0 4px 10px rgba(0,0,0,0.3); transition: all 0.2s; width: 90%;
}
.confirm-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(0,0,0,0.4); }
.confirm-btn:active { transform: translateY(0); }

.chat-section { flex: 0 0 220px; background: #fff; display: flex; flex-direction: column; }
.chat-header {
    background: linear-gradient(135deg, #34495e, #2c3e50); color: #fff; padding: 8px;
    font-weight: 700; font-size: 0.85rem; display: flex; align-items: center; gap: 5px;
}
.live-indicator { width: 8px; height: 8px; background: #e74c3c; border-radius: 50%; animation: livePulse 2s infinite; }
.chat-messages { flex: 1; padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.chat-msg { font-size: 0.8rem; line-height: 1.4; color: #333; }
.chat-msg.system { color: #7f8c8d; font-style: italic; }
.chat-user { font-weight: 700; color: #2c3e50; }
.chat-input-area { border-top: 1px solid #ddd; padding: 8px; background: #f9f9f9; color: #999; font-size: 0.8rem; }

.debug-mode {
    position: fixed; top: 10px; right: 10px;
    background: rgba(0,0,0,0.8); color: var(--gold); padding: 5px 12px;
    border-radius: 20px; font-family: 'Orbitron'; font-size: 0.75rem;
    z-index: 9999; border: 1px solid var(--gold);
}
.flying-chip {
    position: fixed; width: 45px; height: 45px; border-radius: 50%;
    z-index: 9999; pointer-events: none; transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

/* --- Bet confirm / lock UI --- */
.bet-status{
    margin-top: 10px;
    width: 90%;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 8px 10px;
    border-radius: 12px;
    display: none;
    user-select: none;
}
.bet-status.info { background: rgba(52, 152, 219, 0.15); color: #2c3e50; border: 1px solid rgba(52, 152, 219, 0.35); }
.bet-status.success { background: rgba(46, 204, 113, 0.18); color: #145a32; border: 1px solid rgba(46, 204, 113, 0.45); }
.bet-status.warn { background: rgba(231, 76, 60, 0.15); color: #641e16; border: 1px solid rgba(231, 76, 60, 0.35); }

.confirm-btn.confirmed{
    background: linear-gradient(135deg, #1f618d, #154360);
}
.confirm-btn.disabled{
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.betting-table.betting-locked .bet-zone{
    pointer-events: none;
    opacity: 0.75;
}
.chips-section.betting-locked .chip{
    pointer-events: none;
    opacity: 0.55;
}

/* ========== ADMIN MODAL ========== */
.admin-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s;
}

.admin-modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.admin-modal-content {
    background: linear-gradient(135deg, #2c3e50 0%, #1a1a1a 100%);
    border: 3px solid var(--gold);
    border-radius: 20px;
    width: 450px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

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

.admin-header {
    background: linear-gradient(135deg, var(--gold), #e6b800);
    padding: 20px;
    text-align: center;
    color: #000;
}

.admin-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

.admin-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 1.3rem;
    letter-spacing: 3px;
    margin: 0;
}

.admin-body {
    padding: 30px 25px;
}

.admin-info {
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-info label {
    color: #bbb;
    font-size: 0.9rem;
}

.balance-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.admin-input-group {
    margin-bottom: 20px;
}

.admin-input-group label {
    display: block;
    color: #fff;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.admin-input-group input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    transition: all 0.3s;
}

.admin-input-group input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.admin-quick-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.admin-quick-buttons button {
    flex: 1;
    min-width: 70px;
    padding: 10px;
    background: linear-gradient(135deg, #34495e, #2c3e50);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-quick-buttons button:hover {
    background: linear-gradient(135deg, #4a6278, #3d5266);
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.admin-quick-buttons button:active {
    transform: translateY(0);
}

.admin-footer {
    display: flex;
    gap: 10px;
    padding: 0 25px 25px;
}

.admin-btn {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-family: 'Kanit', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.admin-btn.confirm {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: #fff;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

.admin-btn.confirm:hover {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.6);
}

.admin-btn.cancel {
    background: linear-gradient(135deg, #7f8c8d, #5d6d7e);
    color: #fff;
}

.admin-btn.cancel:hover {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    transform: translateY(-3px);
}

.admin-btn:active {
    transform: translateY(0);
}