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

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  min-height: 100vh;
  padding: 20px 10px;
  margin: 0;
  width: 100%;
}

.header {
  text-align: center;
  margin-bottom: 30px;
}

.header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.controls {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  width: 100%;
}

.input-group {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  align-items: center;
}

.input-group label {
  min-width: 120px;
  font-weight: bold;
}

.input-group input,
.input-group select {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
}

.max-games-input {
  width: 50px;
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 13px;
  margin-left: 8px;
}

.martin-badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.martin-badge {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.85);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.martin-badge:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
  transform: translateY(-1px);
}

.martin-badge.active {
  background: rgba(34, 197, 94, 0.25);
  border-color: rgba(34, 197, 94, 0.6);
  color: #4ade80;
  box-shadow: 0 6px 12px rgba(34, 197, 94, 0.2);
}

.stage-radio-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stage-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.stage-radio-label:has(input:checked) {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.5);
  color: #4ade80;
  font-weight: 600;
}

.stage-radio-label input[type='radio'] {
  margin: 0;
  accent-color: #4ade80;
}

.button {
  background: linear-gradient(45deg, #28a745, #20c997);
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 25px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
  margin: 5px;
}

.button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.button.disconnect {
  background: linear-gradient(45deg, #dc3545, #c82333);
}

.dashboard {
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  color: white;
  width: 100%;
}

.dashboard h3 {
  margin: 0 0 20px 0;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 15px;
}

.status-row:last-child {
  margin-bottom: 0;
}

.dashboard-note {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-align: center;
}

.status-item {
  background: rgba(255, 255, 255, 0.15);
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-card {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.12),
    rgba(255, 255, 255, 0.08)
  );
  backdrop-filter: blur(15px);
  border-radius: 12px;
  padding: 16px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(255, 255, 255, 0.05) 50%,
    transparent 100%
  );
  pointer-events: none;
}

.game-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 25px rgba(0, 0, 0, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.game-card.active {
  border: 2px solid #28a745;
  box-shadow:
    0 0 20px rgba(40, 167, 69, 0.4),
    0 4px 16px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  background: linear-gradient(
    145deg,
    rgba(40, 167, 69, 0.1),
    rgba(255, 255, 255, 0.08)
  );
}

.game-card.pending-removal {
  border-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
  opacity: 0.7;
  transform: scale(0.95);
  animation: fadeOut 5s ease-in-out;
}

.removal-warning {
  background: rgba(255, 107, 107, 0.2);
  color: #ff6b6b;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.8em;
  font-weight: bold;
  margin-top: 5px;
  text-align: center;
  border: 1px solid rgba(255, 107, 107, 0.5);
}

@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  80% {
    opacity: 0.7;
    transform: scale(0.95);
  }
  100% {
    opacity: 0.3;
    transform: scale(0.9);
  }
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
  z-index: 1;
}

.game-title {
  font-size: 1.1em;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #fff, #e0e0e0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-status {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.game-status.inactive {
  background: linear-gradient(135deg, #6c757d, #495057);
  box-shadow: 0 2px 4px rgba(108, 117, 125, 0.3);
}

.game-status.betting {
  background: linear-gradient(135deg, #ffc107, #fd7e14);
  color: #212529;
  box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

.game-status.dealing {
  background: linear-gradient(135deg, #17a2b8, #138496);
  box-shadow: 0 2px 4px rgba(23, 162, 184, 0.3);
}

.game-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.info-item {
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
  padding: 8px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.info-item:hover {
  background: rgba(0, 0, 0, 0.3);
  transform: scale(1.02);
}

.info-label {
  font-size: 0.7em;
  opacity: 0.7;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.info-value {
  font-size: 1em;
  font-weight: 600;
  color: #fff;
}

.cards-display {
  display: flex;
  justify-content: space-around;
  margin: 12px 0;
  background: linear-gradient(145deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.2));
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.hand {
  text-align: center;
}

.hand-label {
  font-size: 0.8em;
  opacity: 0.7;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.hand-cards {
  font-size: 1.1em;
  margin-bottom: 4px;
  min-height: 22px;
  font-weight: 500;
}

.hand-score {
  font-size: 1.3em;
  font-weight: 700;
  background: linear-gradient(135deg, #ffc107, #fd7e14);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

.betting-section {
  background: linear-gradient(145deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.2));
  padding: 12px;
  border-radius: 10px;
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.bet-amount {
  text-align: center;
  font-size: 1em;
  margin-top: 8px;
  font-weight: 600;
}

.history {
  background: linear-gradient(145deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.2));
  padding: 12px;
  border-radius: 10px;
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.history-title {
  font-weight: 600;
  font-size: 0.85em;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.history-item {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8em;
  font-weight: 500;
  transition: all 0.2s ease;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  padding-left: 4px;
}

.log-panel {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 15px;
  padding: 20px;
  margin-top: 30px;
  max-height: 300px;
  overflow-y: auto;
  width: 100%;
  box-sizing: border-box;
}

.log-title {
  font-weight: bold;
  margin-bottom: 15px;
  text-align: center;
}

.log-item {
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9em;
  font-family: monospace;
}

@media (max-width: 768px) {
  .games-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 0 5px;
  }

  .game-card {
    padding: 12px;
    border-radius: 10px;
  }

  .game-info {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .cards-display {
    flex-direction: column;
    gap: 8px;
    padding: 10px;
  }

  .input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .input-group label {
    min-width: auto;
    margin-bottom: 5px;
  }
}

/* 🎨 스크롤바 스타일 */
.history::-webkit-scrollbar,
.log-container::-webkit-scrollbar {
  width: 6px;
}

.history::-webkit-scrollbar-track,
.log-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.history::-webkit-scrollbar-thumb,
.log-container::-webkit-scrollbar-thumb {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.3),
    rgba(255, 255, 255, 0.2)
  );
  border-radius: 3px;
}

.history::-webkit-scrollbar-thumb:hover,
.log-container::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.4),
    rgba(255, 255, 255, 0.3)
  );
}

/* 📊 차트 컨테이너 스타일 */
.chart-container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 20px;
  margin: 30px auto;
  width: 100%;
  max-width: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.chart-title {
  text-align: center;
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.chart-wrapper {
  height: 420px !important;
  width: 100% !important;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: visible !important;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
}

#profitChart {
  width: 100% !important;
  height: 400px !important;
  min-height: 400px !important;
  display: block !important;
  background: rgba(0, 0, 0, 0.1);
  position: relative !important;
  z-index: 1 !important;
  border-radius: 8px;
  box-sizing: border-box;
}

/* 🎰 베팅 테이블 카드 스타일 */
.betting-table-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.betting-table-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.4),
    0 0 30px currentColor;
}

.betting-table-card.result-blink {
  animation: resultBlink 1s ease-in-out 3;
}

@keyframes resultBlink {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.9);
  }
}

/* 🎨 gamesGrid 베팅 카드 컨테이너 */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
  width: 100%;
  box-sizing: border-box;
  padding: 0 10px;
}

/* 📱 반응형 조정 */
@media (max-width: 768px) {
  .games-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 0 8px;
  }

  .betting-table-card {
    padding: 16px !important;
  }
}

@media (min-width: 1200px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
  }
}

/* 🌟 조건별 글로우 효과 */
.betting-table-card[data-condition='1'] {
  border-color: #4caf50 !important;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(76, 175, 80, 0.4) !important;
}

.betting-table-card[data-condition='2'] {
  border-color: #ff9800 !important;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(255, 152, 0, 0.4) !important;
}

/* 🎲 SVG 6매 그림 컨테이너 - 고정 크기 */
.sixboard-container {
  background: linear-gradient(145deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.2));
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  /* 고정 크기 설정 */
  width: 100%;
  height: 180px;
  min-height: 180px;
  max-height: 180px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sixboard-container svg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ✨ 부드러운 페이드 효과 (깜빡임 제거) */
/* pulse-glow 애니메이션 비활성화 - 깜빡임 대신 페이드 효과 사용 */
/*
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 10px currentColor;
  }
  50% {
    box-shadow: 0 0 25px currentColor;
  }
}
*/

/* 깜빡이는 효과 제거 - 클래스는 유지하되 애니메이션 없음 */
.betting-table-card.pulse {
  /* animation: pulse-glow 2s ease-in-out infinite; */
  transition: all 0.5s ease;
}

.table-list-stat {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
}

.stat-win {
  background: rgba(40, 167, 69, 0.3);
  color: #7fff7f;
}

.stat-lose {
  background: rgba(220, 53, 69, 0.3);
  color: #ff7f7f;
}

.stat-margin {
  background: rgba(255, 193, 7, 0.3);
  color: #ffc107;
}

.stat-streak {
  background: rgba(102, 126, 234, 0.3);
  color: #a5b4fc;
}

.stat-games {
  background: rgba(108, 117, 125, 0.3);
  color: #adb5bd;
}

/* ========================================
   🎯 통합 테이블 뷰 스타일 (Unified Table View)
   ======================================== */

/* 💰 베팅 중인 테이블 하이라이트 */
.betting-table-card.active-betting {
  animation: activeBettingGlow 3s ease-in-out infinite;
}

@keyframes activeBettingGlow {
  0%,
  100% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.3),
      0 0 20px rgba(255, 193, 7, 0.3);
  }
  50% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.3),
      0 0 35px rgba(255, 193, 7, 0.5);
  }
}

/* 📋 비베팅 테이블 */
.betting-table-card.non-betting {
  transition: all 0.3s ease;
}

.betting-table-card.non-betting:hover {
  opacity: 1 !important;
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* 🎯 결과 오버레이 — 스무스 반투명 페이드 */
.result-overlay {
  animation: smoothFadeIn 0.6s ease-out;
  backdrop-filter: blur(6px);
}

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

/* 📝 결과 오버레이 공통 요소 스타일 */
.result-overlay .result-emoji {
  font-size: 36px;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.result-overlay .result-text {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.result-overlay .result-payout {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.result-overlay .result-game-name {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 6px;
}

.result-overlay .result-sub-text {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 3px;
}

/* 🔄 통합 그리드 헤더 */
.unified-grid-header {
  grid-column: 1 / -1;
  text-align: center;
  padding: 8px 16px;
  margin-bottom: 4px;
  color: #ffc107;
  font-weight: bold;
  font-size: 14px;
}
