/* AI 추출 모달 */
.modal-overlay {  
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  visibility: hidden; /* display: none 대신 사용해야 애니메이션이 먹힘 */
  transition: opacity 0.5s ease, visibility 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;  
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.modal-container {
  animation:none;
  background: #030521;
  border: 2px solid #1624b2;
  border-radius: 20px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 40px 30px;
  box-shadow: 
    0 0 50px rgba(22, 36, 178, 0.3),
    0 0 100px rgba(22, 36, 178, 0.1);  
  transform-origin: center;
  margin: auto;  
  opacity: 0;
  transform: translateY(-30px) scale(1); /* 위로 가면서 작아지게 */  
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), 
              opacity 0.4s ease,
              max-height 0.5s ease-in-out; /* 높이가 변할 때 부드럽게 */
  
  display: flex;
  flex-direction: column;
}

/* 열렸을 때 컨테이너 상태 */
.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* 게임 카드가 담기는 내부 박스 */
.games-container {
  display: flex;
  flex-direction: column;
  gap: 15px;  
  transition: all 0.5s ease-in-out; 
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 모달닫기 */
.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  color: #ffffff;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex; 
  align-items: center;
  justify-content: center;
  opacity: 0; /* 투명도로 숨김 */
  pointer-events: none; /* 클릭 방지 */
}

.modal-close.show {
  opacity: 1;
  pointer-events: auto; /* 클릭 가능 */
}

.modal-close:hover {
  background: rgba(22, 36, 178, 0.2);
  border-color: #1624b2;
  transform: rotate(90deg);
}

/* 모달 헤더 */
.modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.ai-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  background: linear-gradient(135deg, #6B6BFF 0%, #4b20c3 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'kbl';
  font-size:12px;
  color: #ffffff;
  position: relative;
  animation: aiPulse 2s ease-in-out infinite;
}

.ai-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid #4b20c3;
  border-radius: 50%;
  animation: pulse-ring 2s ease-out infinite;

}

@keyframes aiPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(107, 107, 255, 0.5);
  }
  50% {
    box-shadow: 0 0 40px rgba(107, 107, 255, 0.8);
  }
}

@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.modal-title {
  font-size: 35px;  
  color: #ffffff;
  margin-bottom: 8px;  
  font-family : 'kbl';
}

.modal-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Pretendard';
}

/* 게임 카드들이 들어가는 부모 컨테이너 */
#gamesContainer {
  display: flex;
  flex-direction: column;
  gap: 15px;
  /* 컨테이너 자체가 늘어날 때 부드럽게 */
  transition: all 0.5s ease-in-out; 
}

/* 개별 게임 카드 (기본: 숨김 상태) */
.game-card {
  background: #0a0c34;
  border: 1px solid #191e70;
  border-radius: 12px;
  padding: 0 20px;      /* 높이가 0일 땐 패딩도 세로값은 0으로 */
  opacity: 0;
  max-height: 0;        /* 높이 봉인 */
  overflow: hidden;     /* 내용물 봉인 */
  transform: translateY(20px); /* 아래에서 위로 올라오는 효과용 */
  transition: 
    max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
    padding 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.4s ease,
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 자바스크립트에서 클래스가 붙으면 활성화 (보임 상태) */
.game-card.show-card {
  opacity: 1;
  max-height: 300px;    /* 넉넉하게 카드 높이 확보 */
  padding: 20px;       /* 원래 패딩 복구 */
  transform: translateY(0);
  margin-bottom: 5px;   /* 카드 사이 간격 보조 */
}

@keyframes gameSlideIn {
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 200px; /* 카드의 최대 높이 (넉넉하게 설정) */
    margin-bottom: 0;
    padding: 20px; /* 원래 패딩값으로 복구 */
  }
}

.game-card:nth-child(1) { animation-delay: 0.1s; }
.game-card:nth-child(2) { animation-delay: 0.3s; }
.game-card:nth-child(3) { animation-delay: 0.5s; }
.game-card:nth-child(4) { animation-delay: 0.7s; }
.game-card:nth-child(5) { animation-delay: 0.9s; }

@keyframes gameSlideIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.game-number {
  font-size: 12px;
  font-weight: 600;
  color: #6B6BFF;
  font-family: 'Pretendard';
  display: flex;
  align-items: center;
  gap: 5px; /* 점과 텍스트 간격 */
}

/* 펄스 효과 추가 */
.game-live-dot {
  width: 6px;
  height: 6px;
  background-color: #00ff88;
  border-radius: 50%;
  animation: gameBlink 1.5s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(0, 255, 136, 0.8);
  position: relative;
}

.game-live-dot::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: rgba(0, 255, 136, 0.4);
  animation: gameRipple 1.5s ease-out infinite;
}

@keyframes gameBlink {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.9);
  }
}

@keyframes gameRipple {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

.game-label {
    display: inline-flex; /* 아이콘과 텍스트 가로 정렬 */
    align-items: center;  /* 수직 중앙 정렬 */
    background: rgba(0, 255, 136, 0.1); /* 연한 녹색 배경 */
    color: #00ff88; /* 포인트 컬러 */
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;    
    gap: 3px;
}

.game-label-backup {
  font-size: 12px;
  color: #01ea7f;
  background: rgba(107, 107, 255, 0.1);
  padding: 4px 10px;
  border-radius: 10px;
  border:1px solid #232675;
}

.numbers-grid {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.number-ball {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family:'Orbitron','Pretendard';
  font-size: 20px;  
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, #6B6BFF 0%, #4D4DFF 100%);
  box-shadow:     
  animation: numberPop 0.3s ease-out;
  text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.6);
}

@keyframes numberPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 번호 색상 (로또 공식 색상) */
.number-ball.yellow { background: linear-gradient(135deg, #FFC107 0%, #FF9800 100%); border:1px solid #ffd684; }
.number-ball.blue { background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%); border:1px solid #50bfff; }
.number-ball.red { background: linear-gradient(135deg, #F44336 0%, #D32F2F 100%); border:1px solid #ff6a47; }
.number-ball.gray { background: linear-gradient(135deg, #9E9E9E 0%, #757575 100%); border:1px solid #b1b1b1; }
.number-ball.green { background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%); border:1px solid #55c85a; }

/* 분석 상태 */
.analysis-status {
  margin-bottom: 30px;
  max-height: 100px;
  overflow: hidden;
}

@keyframes completePulse {
  0%, 100% {
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.8);
  }
  50% {
    text-shadow: 0 0 20px rgba(0, 255, 136, 1), 0 0 30px rgba(0, 255, 136, 0.6);
  }
}

/* 모달 푸터 버튼 영역 */
.modal-footer {
  display: flex;
  gap: 15px;
  margin-top: 15px;
  padding: 0;
  /*border-top: 1px solid rgba(255, 255, 255, 0.05);*/
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.5s ease;
}

.modal-footer.show {
  opacity: 1;
  transform: translateY(0);
}

.footer-btn {
  flex: 1;
  padding: 14px 0;
  border-radius: 12px;
  font-size: 15px;  
  cursor: pointer;  
  font-family: 'Pretendard';
  transition: all 0.3s ease;
}

.btn-retry {
  background: #1624b2;
  border:1px solid #2f40ec;
  color: white;
}

.btn-retry:hover {
  background: #192be1;
}

.btn-close-footer {
  background: #10122c;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-close-footer:hover {
  background: rgba(255, 255, 255, 0.03); /* 투명도를 높여서 더 밝게 보이게 함 */
  color: #ffffff; /* 글자색을 완전 하얗게 */
  border-color: #1d1f39; /* 보더를 더 진하게 */  
}

/* 반응형 */
@media (max-width: 768px) {
  .modal-container {
    margin: 20px;
    padding: 30px 20px;
  }
  
  .modal-title {
    font-size: 22px;
  }
  
  .numbers-grid {
    gap: 5px;
  }
  
  .number-ball {
    width: 35px;
    height: 35px;
    font-size: 18px;
  }

  .game-label {
  font-size: 10px;  
  }
}

/* 반응형 - 작은 모바일 */
@media (max-width: 480px) {
  .numbers-grid {
    gap: 8px;
  }
  
  .number-ball {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }  

  .game-card.show-card { padding:10px !improtant;  }

  .modal-close {  
  width: 30px;
  height: 30px;  
  font-size: 20px;  
  }

    .modal-footer {
        gap: 10px;
    }
    .footer-btn {
        font-size: 14px;
        padding: 12px 0;
    }
}

/* 반응형 - 작은 모바일 */
@media (max-width: 360px) {

  .numbers-grid {
    gap: 2px;
  }
  
  .number-ball {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .game-card.show-card { padding:10px !important; }

  .modal-close {  
  width: 20px;
  height: 20px;  
  font-size: 15px;  
  }

    .modal-footer {
        gap: 10px;
    }
    .footer-btn {
        font-size: 14px;
        padding: 12px 0;
    }
}

/* 슬롯머신 효과 */
.number-ball .number-value {
  display: block;
  transition: all 0.1s ease;
}

.number-ball.final {
  animation: finalPop 0.4s ease-out;
}

@keyframes finalPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
    box-shadow: 
      0 6px 20px rgba(107, 107, 255, 0.6),
      inset 0 2px 0 rgba(255, 255, 255, 0.5);
  }
  100% {
    transform: scale(1);
  }
}

/* 번호 변경시 글로우 효과 */
.number-ball {
  position: relative;
  transition: all 0.1s ease;
}

/* 모달 컨테이너 스크롤바 */
/* 1. AI 추출 모달 (modal-container) - 심플한 파란색 */
#aiModal .modal-container::-webkit-scrollbar {
  width: 6px; /* 스크롤바 너비 */
}

#aiModal .modal-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05); /* 트랙 배경 (매우 연하게) */
  border-radius: 10px;
}

#aiModal .modal-container::-webkit-scrollbar-thumb {
  background: #1624b2; /* 심플한 파란색 */
  border-radius: 10px;
}

/* 분석 상태 */
.analysis-status {
  margin-bottom: 30px;
}

.status-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0px;
}

.status-progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #1624b2 0%, #00d4ff 50%, #01ea7f 100%);
  border-radius: 10px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(107, 107, 255, 0.5);
}

.status-text {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-family: 'Pretendard';
}