/* --- styles.css --- */

body {
  font-family: 'Pretendard', Arial, sans-serif;
  background: #eef2f5;
  margin: 0;
  display: flex;
  justify-content: center;
  /* 모바일 키보드 팝업 시 화면 짤림 방지를 위해 수정 */
  align-items: flex-start; 
  min-height: 100vh;
  padding: 20px 0;
  box-sizing: border-box;
}

.container {
  width: 95%;
  max-width: 500px;
  background: white;
  padding: 30px 20px;
  border-radius: 20px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.1);
  text-align: center;
  /* body의 align-items: flex-start 속성과 결합하여 화면 중앙 정렬 */
  margin: auto; 
}

h1 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 24px;
  color: #333;
}

.info {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: bold;
  color: #666;
  margin-bottom: 15px;
  padding: 0 10px;
}

.status-area {
  font-size: 20px;
  font-weight: bold;
  color: #ff4757;
  min-height: 30px;
  margin-bottom: 15px;
}

.question {
  font-size: 22px;
  margin-bottom: 20px;
  font-weight: bold;
  color: #2f3542;
  background: #f1f2f6;
  padding: 15px;
  border-radius: 12px;
}

.dice-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin-bottom: 25px;
  min-height: 80px;
}

/* 주사위 디자인 */
.dice {
  width: 65px;
  height: 65px;
  border-radius: 16px;
  position: relative;
  box-shadow: inset 0 6px rgba(255,255,255,0.4), 
              inset 0 -6px rgba(0,0,0,0.15), 
              0 8px 15px rgba(0,0,0,0.2);
  animation: rollIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  opacity: 0;
  transform: scale(0);
}

@keyframes rollIn {
  0% { transform: scale(0) rotate(-720deg) translateY(50px); opacity: 0; }
  100% { transform: scale(1) rotate(0) translateY(0); opacity: 1; }
}

/* 주사위 점 */
.dot {
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  position: absolute;
  box-shadow: inset 0 3px rgba(0,0,0,0.1);
}

/* 점 위치 설정 */
.dot.center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.dot.top-left { top: 12px; left: 12px; }
.dot.top-right { top: 12px; right: 12px; }
.dot.bottom-left { bottom: 12px; left: 12px; }
.dot.bottom-right { bottom: 12px; right: 12px; }
.dot.middle-left { top: 50%; left: 12px; transform: translateY(-50%); }
.dot.middle-right { top: 50%; right: 12px; transform: translateY(-50%); }

.answer-area {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 15px;
}

input {
  padding: 12px;
  /* 모바일 확대 방지를 위해 input 폰트 사이즈는 최소 16px 유지 */
  font-size: 18px; 
  width: 120px;
  border-radius: 10px;
  border: 2px solid #dfe4ea;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

input:focus { border-color: #4f46e5; }

button {
  padding: 12px 20px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: #4f46e5;
  color: white;
  transition: transform 0.1s, opacity 0.2s;
}

button:active { transform: scale(0.95); }
button:hover { opacity: 0.9; }

.btn-primary {
  width: 100%;
  max-width: 200px;
  font-size: 18px;
  padding: 15px;
  background: #ff4757;
}

#result {
  margin-top: 15px;
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: bold;
  color: #2f3542;
}

.hidden { display: none !important; }

/* 팝업 모달 */
.top-bar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.btn-secondary { background: #f1c40f; color: #2f3542; padding: 8px 15px; font-size: 14px; border-radius: 8px; box-shadow: 0 3px 6px rgba(0,0,0,0.1); }
.btn-secondary:hover { background: #f39c12; }

.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center;
  z-index: 1000; backdrop-filter: blur(2px);
}
.modal-content {
  background: white; padding: 25px 20px; border-radius: 15px;
  width: 85%; max-width: 350px; position: relative; box-shadow: 0 10px 30px rgba(0,0,0,0.3); text-align: center;
  animation: popModal 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popModal {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.close-btn { position: absolute; top: 15px; right: 20px; font-size: 28px; cursor: pointer; color: #999; line-height: 1; }
.close-btn:hover { color: #ff4757; }
.modal-content h3 { margin: 0 0 15px 0; font-size: 20px; color: #f1c40f; text-shadow: 1px 1px 0px rgba(0,0,0,0.1); }
#leaderboardList { list-style: none; padding: 0; margin: 0; text-align: left; }
#leaderboardList li { display: flex; justify-content: space-between; padding: 10px 5px; border-bottom: 1px dashed #dcdde1; font-size: 15px; color: #2f3542; }
#leaderboardList li:last-child { border-bottom: none; }
#leaderboardList li span.rank { font-weight: bold; color: #ff4757; width: 35px; }
#leaderboardList li span.name { flex-grow: 1; font-weight: bold; }
#leaderboardList li span.score { color: #4f46e5; font-weight: bold; }

.game-over-area { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
#nicknameInput { width: 100%; max-width: 200px; }
#saveScoreBtn { background: #2ed573; width: 100%; max-width: 200px; }
.button-group { display: flex; justify-content: center; gap: 10px; margin-top: 15px; width: 100%; }
#saveScoreBtn, #startBtn { width: auto; flex: 1; max-width: 160px; margin: 0; }


/* =========================================
   모바일 최적화 미디어 쿼리 (화면 너비 480px 이하)
   ========================================= */
@media screen and (max-width: 480px) {
  .container {
    padding: 20px 15px;
    width: 100%;
  }

  h1 { font-size: 20px; }
  .info { font-size: 16px; margin-bottom: 10px; }
  .status-area { font-size: 16px; min-height: 24px; }
  .question { font-size: 18px; padding: 12px; }

  /* 주사위 개수가 많아질 것을 대비해 크기 축소 */
  .dice-container { gap: 10px; }
  .dice {
    width: 45px;
    height: 45px;
    border-radius: 12px;
  }
  
  /* 주사위 점 크기 및 위치 축소 조정 */
  .dot { width: 10px; height: 10px; }
  .dot.top-left { top: 8px; left: 8px; }
  .dot.top-right { top: 8px; right: 8px; }
  .dot.bottom-left { bottom: 8px; left: 8px; }
  .dot.bottom-right { bottom: 8px; right: 8px; }
  .dot.middle-left { left: 8px; }
  .dot.middle-right { right: 8px; }

  /* 정답 입력 영역을 세로로 변경하여 터치하기 쉽게 구성 */
  .answer-area {
    flex-direction: column;
    align-items: center;
  }
  input { width: 100%; max-width: 250px; }
  #submitBtn { width: 100%; max-width: 250px; }

  /* 하단 버튼 그룹도 세로 배치로 변경 */
  .button-group {
    flex-direction: column;
    align-items: center;
  }
  #saveScoreBtn, #startBtn {
    width: 100%;
    max-width: 250px;
    flex: none;
  }
}