/* 기본 폰트 설정 */
body {
    font-family: 'Inter', sans-serif;
    background-color: #1a1a1a;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    min-height: 100vh;
    padding: 20px;
}

/* 컨테이너 및 레이아웃 */
.container {
    width: 100%;
    max-width: 1280px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

/* 영상 관련 스타일 */
.video-wrapper {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    position: relative;
}

iframe {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
}

.shuffle-screen {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
}

@media (min-width: 1025px) {
    .shuffle-screen {
        height: 100%;
        aspect-ratio: auto;
    }
}

/* 영상 클릭 방지 오버레이 */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: transparent;
}

/* 버튼 스타일 그룹 */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.login-button, .admin-button, .exit-button {
    padding: 15px 25px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    border: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.login-button:hover, .admin-button:hover, .exit-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3);
}

.login-button { background-image: linear-gradient(135deg, #10b981, #059669); color: white; }
.user-login-button { background-image: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.admin-button { background-image: linear-gradient(135deg, #ef4444, #dc2626); color: white; }
.exit-button { background-color: #4b5563; color: #e5e7eb; }

/* 신규 로그인 버튼 스타일 */
.login-btn-new {
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.login-btn-new:hover { opacity: 0.9; transform: translateY(-2px); }
.login-btn-blue { background-color: #3b82f6; }
.login-btn-green { background-color: #22c55e; }
.login-btn-grey { background-color: #4b5563; font-size: 1rem; padding: 12px 20px; }

/* 유틸리티 */
.hidden-admin-btn { display: none; }
.hidden-view {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: -9999px;
    left: -9999px;
}

/* 모달 스타일 */
#message-box, #pass-message-box, #balance-check-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffffff;
    color: #1a1a1a;
    padding: 25px 35px;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 3000;
    display: none;
    text-align: center;
}
#message-box h3 { font-size: 1.5rem; font-weight: bold; margin-bottom: 10px; }
#message-box p { font-size: 1.1rem; }

#confirm-modal, #password-modal, #add-agent-modal, #edit-agent-modal, #assign-users-modal, #table-settings-modal, #add-dealer-modal, #history-modal, #edit-dealer-modal, #add-user-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background-color: #1a1a1a;
    color: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    width: 90%;
    max-width: 400px;
}
.modal-content input, .modal-content select {
    background-color: #333;
    border: 1px solid #666;
    color: white;
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 20px;
    text-align: center;
}
.modal-buttons { display: flex; justify-content: center; gap: 15px; margin-top: 1rem; }
.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
}
.modal-buttons button:hover { transform: translateY(-2px); }
.confirm-ok { background-color: #059669; color: white; }
.confirm-cancel { background-color: #dc2626; color: white; }
.password-submit { background-color: #1d4ed8; color: white; }

/* 히스토리 테이블 */
#history-modal .modal-content { max-width: 900px; }
#history-content { max-height: 60vh; overflow-y: auto; }
.history-table { width: 100%; border-collapse: collapse; }
.history-table th, .history-table td { padding: 8px; text-align: center; border-bottom: 1px solid #444; }
.history-table th { background-color: #333; font-weight: bold; }
.history-table tr:hover { background-color: #2c2c2c; }

/* 관리자/에이전트 뷰 그리드 */
#admin-view .bet-header, #admin-view .user-bet-item {
    display: grid;
    gap: 10px;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    align-items: center;
}
#admin-view .bet-header.admin-view-grid { background-color: #4b5563; }
#admin-view .bet-header.agent-view-grid { background-color: #4b5563; }
#admin-view .bet-header.agent-list-grid { grid-template-columns: 1fr 1fr 1fr 240px; background-color: #4b5563; }
#admin-view .bet-header.dealer-list-grid { grid-template-columns: 1fr 1fr 1fr 120px; background-color: #4b5563; }

#admin-view .user-bet-item { background-color: #2c2c2c; font-weight: normal; }
#admin-view .user-bet-item.agent-list-grid { grid-template-columns: 1fr 1fr 1fr 240px; }
#admin-view .user-bet-item.dealer-list-grid { grid-template-columns: 1fr 1fr 1fr 120px; }

#admin-view .user-bet-item input {
    background-color: #1a1a1a;
    color: white;
    padding: 5px;
    border-radius: 4px;
    text-align: center;
    width: 100%;
    border: 1px solid #4b5563;
}
#admin-view .user-bet-item .reset-btn,
#admin-view .user-bet-item .history-btn,
#admin-view .user-bet-item .agent-action-btn {
    background-color: #000;
    color: white;
    border: none;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color: 0.2s;
}
#admin-view .user-bet-item .reset-btn:hover,
#admin-view .user-bet-item .history-btn:hover,
#admin-view .user-bet-item .agent-action-btn:hover { background-color: #333; }

/* 배팅 텍스트 색상 */
.bet-color-player { color: #3b82f6; }
.bet-color-tie { color: #22c55e; }
.bet-color-banker { color: #ef4444; }
.bet-color-side { color: #eab308; }
.bet-color-default { color: #ffffff; }

/* 배팅 메시지 */
.bet-end-message, .bet-start-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #facc15;
    padding: 20px 40px;
    border-radius: 15px;
    border: 2px solid #facc15;
    font-size: 2.5rem;
    font-weight: bold;
    text-align: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
}
.bet-end-message.show, .bet-start-message.show { opacity: 1; }

/* 유저 뷰 레이아웃 */
#user-view.side-by-side {
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
}
.left-panel { flex: 2; display: flex; flex-direction: column; gap: 20px; }
.right-panel {
    flex: 1;
    background-color: #1a3a2a;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 2px solid #a37b0a;
}

/* 유저 정보 패널 */
.user-info-panel {
    background-color: #0c2b1e;
    border-radius: 8px;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap-y: 8px;
    border: 1px solid #1a3a2a;
}
.user-info-panel .info-value { color: #e5e7eb; font-weight: bold; font-size: 0.9rem; }
#selected-amount-display { color: #facc15; }

/* 배팅 그리드 */
.betting-grid-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: #0c2b1e;
    padding: 8px;
    border-radius: 8px;
}
.betting-grid-row { display: grid; gap: 8px; }
.betting-grid-row.top-bets { grid-template-columns: repeat(4, 1fr); }
.betting-grid-row.middle-bets { grid-template-columns: repeat(3, 1fr); }
.betting-grid-row.main-bets { grid-template-columns: repeat(2, 1fr); }

.bet-area {
    background-color: #1a3a2a;
    border: none;
    border-radius: 4px;
    padding: 1rem 0.5rem;
    gap: 0.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}
.bet-area.disabled { cursor: not-allowed; opacity: 0.7; }
.bet-area:not(.disabled):hover { background-color: rgba(255, 255, 255, 0.1); }
.bet-title { font-size: 1.1rem; font-weight: 700; text-shadow: none; }
.bet-odds { font-size: 0.75rem; color: #d1d5db; }
.bet-amount-on-table {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.8rem;
    color: #000;
    background-image: repeating-conic-gradient(#c084fc 0% 12.5%, #fff 12.5% 25%);
    border: 2px solid #fff;
    box-shadow: 0 5px 10px rgba(0,0,0,0.35), inset 0 2px 3px rgba(0,0,0,0.3);
    text-shadow: none;
    z-index: 10;
}
.bet-amount-on-table::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #f9f9f9;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.25);
}
.bet-amount-on-table span { position: relative; z-index: 2; }

/* 칩 캐러셀 */
.chip-carousel-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 0.5rem;
    gap: 5px;
}
.chip-track { display: flex; justify-content: center; gap: 8px; flex: 1; }
.chip-nav-btn {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid #4b5563;
    color: #e5e7eb;
    width: 30px;
    height: 60px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 1.2rem;
    padding: 0;
}
.chip-nav-btn:hover:not(:disabled) { background-color: rgba(255, 255, 255, 0.1); }
.chip-nav-btn:disabled { opacity: 0.3; cursor: default; }

/* 칩 스타일 */
.chip {
    width: 60px; height: 60px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-weight: bold; font-family: 'Arial Black', Gadget, sans-serif; font-size: 0.9rem;
    cursor: pointer; position: relative;
    box-shadow: 0 5px 10px rgba(0,0,0,0.35), inset 0 2px 3px rgba(0,0,0,0.3);
    transition: all 0.2s ease-out;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    border: 2px solid #fff; padding: 0; background-color: #ddd;
}
.chip::before {
    content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 42px; height: 42px; border-radius: 50%; background: #f9f9f9;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.25);
}
.chip span { position: relative; z-index: 2; }
.chip:hover { transform: translateY(-4px) scale(1.05); box-shadow: 0 8px 15px rgba(0,0,0,0.4), inset 0 2px 3px rgba(0,0,0,0.3); }
.chip.disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; transform: none; box-shadow: 0 5px 10px rgba(0,0,0,0.35), inset 0 2px 3px rgba(0,0,0,0.3); }

/* 칩 색상 (그라데이션) */
.chip-10 { background-image: repeating-conic-gradient(#94a3b8 0% 12.5%, #fff 12.5% 25%); color: #0f172a; }
.chip-50 { background-image: repeating-conic-gradient(#f87171 0% 12.5%, #fff 12.5% 25%); color: #7f1d1d; }
.chip-100 { background-image: repeating-conic-gradient(#60a5fa 0% 12.5%, #fff 12.5% 25%); color: #1e3a8a; }
.chip-500 { background-image: repeating-conic-gradient(#c084fc 0% 12.5%, #fff 12.5% 25%); color: #581c87; }
.chip-1k { background-image: repeating-conic-gradient(#22d3ee 0% 12.5%, #fff 12.5% 25%); color: #155e75; }
.chip-5k { background-image: repeating-conic-gradient(#facc15 0% 12.5%, #fff 12.5% 25%); color: #854d0e; }
.chip-10k { background-image: repeating-conic-gradient(#4ade80 0% 12.5%, #fff 12.5% 25%); color: #166534; }
.chip-50k { background-image: repeating-conic-gradient(#fb923c 0% 12.5%, #fff 12.5% 25%); color: #9a3412; }
.chip-all-in { background-image: repeating-conic-gradient(#ef4444 0% 12.5%, #fff 12.5% 25%); color: #b91c1c; }

/* 액션 버튼 */
.action-button.disabled { opacity: 0.5; cursor: not-allowed; }
.action-button-new {
    border-radius: 8px; color: #ffffff; padding: 10px 20px;
    font-weight: bold; font-size: 0.95rem; cursor: pointer;
    transition: opacity 0.2s ease-in-out; border: none;
}
.action-button-new:hover { opacity: 0.9; }
.btn-cancel { background-color: #eab308; }
.btn-reset { background-color: #f97316; }
.btn-exit-user { background-color: #4b5563; }

/* 딜러 뷰 스타일 */
#dealer-view .result-button {
    padding: 1rem; font-size: 1.1rem; font-weight: bold; border-radius: 12px;
    cursor: pointer; transition: all 0.2s ease; background-color: #374151;
    color: #e5e7eb; border: 2px solid transparent;
}
#dealer-view .result-button:disabled { opacity: 0.5; cursor: not-allowed; background-image: none; background-color: #4b5563; }
#dealer-view .result-button.selected { background-color: #facc15; color: #1a1a1a; border-color: #fff; transform: scale(1.05); }
.start-button-bg { background-image: linear-gradient(135deg, #22c55e, #16a34a); }
.end-button-bg { background-image: linear-gradient(135deg, #3b82f6, #2563eb); }
.send-button-bg { background-image: linear-gradient(135deg, #ef4444, #dc2626); }
.reset-button-bg { background-image: linear-gradient(135deg, #f97316, #ea580c); }

/* 결과 디스플레이 */
#result-display {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8); color: #facc15; padding: 20px 40px;
    border-radius: 15px; border: 2px solid #facc15; font-size: 2.5rem;
    font-weight: bold; text-align: center; z-index: 100;
    opacity: 0; transition: opacity 0.5s ease-in-out; pointer-events: none;
}
#result-display.show { opacity: 1; }

/* 유저 배당 리스트 */
#assign-users-list.grid-layout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
#assign-users-list .user-assign-item {
    display: flex; align-items: center; background-color: #374151;
    padding: 10px; border-radius: 8px; border: 1px solid #4b5563;
    transition: background-color 0.2s;
}
#assign-users-list .user-assign-item:hover { background-color: #4b5563; }
#assign-users-list .user-assign-item input { width: 1.1rem; height: 1.1rem; margin-right: 10px; }
#assign-users-list .user-assign-item label { font-weight: 500; }

/* 테이블 선택 카드 */
.table-card {
    background-color: #ffffff; border: 1px solid #4b5563; border-radius: 8px;
    overflow: hidden; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
}
.table-card:hover { transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0, 0.2); }
.table-card-header {
    background-color: #f3f4f6; color: #1a1a1a; padding: 8px;
    text-align: center; font-weight: bold; border-bottom: 1px solid #d1d5db;
}
.table-card-scoreboard {
    display: grid; grid-template-columns: repeat(20, 1fr); grid-template-rows: repeat(6, 1fr);
    background-color: #ffffff; height: 180px;
    background-image: linear-gradient(to right, #e5e7eb 1px, transparent 1px), linear-gradient(to bottom, #e5e7eb 1px, transparent 1px);
    background-size: calc(100% / 20) calc(100% / 6); border-bottom: 1px solid #d1d5db;
}
.scoreboard-cell { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; position: relative; }
.circle { width: 80%; height: 80%; border-radius: 50%; display: flex; justify-content: center; align-items: center; }
.player-circle { background-color: #3b82f6; }
.banker-circle { background-color: #ef4444; }
.tie-text { color: white; font-weight: bold; font-size: 0.8rem; }

.table-card-footer {
    padding: 8px; display: flex; justify-content: space-around; align-items: center;
    background-color: #f9fafb; color: #1a1a1a; font-size: 0.9rem; font-weight: 500;
}
.footer-stat { display: flex; align-items: center; gap: 5px; }
.circle-sm { width: 14px; height: 14px; border-radius: 50%; }
.tie-circle { background-color: #22c55e; }

/* 채팅 메시지 */
.chat-message {
    padding: 8px 12px; border-radius: 12px; max-width: 80%; display: flex; flex-direction: column;
}
.chat-message.user { background-color: #3b82f6; align-self: flex-end; }
.chat-message.admin { background-color: #4b5563; align-self: flex-start; }
.chat-message .sender { font-size: 0.75rem; font-weight: bold; margin-bottom: 2px; color: #e5e7eb; }

/* 셔플 중 상태 */
.table-card.shuffling { position: relative; cursor: not-allowed; pointer-events: none; }
.table-card.shuffling::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7); border-radius: 8px; z-index: 1;
}
.table-card.shuffling::after {
    content: '셔플중'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: white; font-size: 1.5rem; font-weight: bold; z-index: 2;
}

/* 모바일 반응형 */
@media (max-width: 1024px) {
    body {
        padding: 10px; min-height: 100vh; height: auto;
        overflow-y: auto; display: flex; flex-direction: column;
        justify-content: flex-start; align-items: center;
    }
    .container {
        height: auto; justify-content: flex-start; gap: 10px;
        max-width: none; width: 100%; padding-bottom: 20px;
    }
    #login-screen { margin-top: auto; margin-bottom: auto; }
    #user-view.side-by-side { flex-direction: column; align-items: center; height: auto; gap: 10px; }
    .left-panel { width: 100%; max-width: none; flex: 0 0 auto; }
    .right-panel {
        width: 100%; max-width: none; flex: 1 1 auto; overflow-y: visible;
        padding: 10px; gap: 8px; min-height: 0;
    }
    .user-info-panel { padding: 8px; gap-y: 2px; }
    .user-info-panel .info-value { font-size: 0.8rem; }
    .betting-grid-container { gap: 4px; padding: 4px; }
    .betting-grid-row { gap: 4px; }
    .bet-area { padding: 0.5rem 0.2rem; min-height: 50px; gap: 0; }
    .bet-title { font-size: 0.9rem; margin-bottom: 0; }
    .bet-odds { font-size: 0.7rem; }
    .chip { width: 40px; height: 40px; font-size: 0.7rem; }
    .chip::before { width: 28px; height: 28px; }
    .chip-nav-btn { width: 25px; height: 40px; font-size: 1rem; }
    .chip-carousel-container { margin-top: 0; gap: 2px; }
    .action-button-new { padding: 8px; font-size: 0.8rem; }
    #result-display { font-size: 1.5rem; padding: 10px 20px; }
    .bet-end-message, .bet-start-message {
        font-size: 1.2rem; padding: 10px 20px; width: auto; max-width: 90%;
        border-width: 1px; white-space: nowrap;
    }
}

@media (max-width: 640px) {
    .bet-area { min-height: 45px; }
    .chip { width: 35px; height: 35px; font-size: 0.65rem; }
    .chip::before { width: 24px; height: 24px; }
}