:root {
  --sky-blue-dream: #A0E9FF;
  --morning-mist: #E0F7FA;
  --cotton-candy: #FFFFFF;
  --angry-storm: #FFB7B2;
  --golden-sun: #FFD700;
  --minty-fresh: #98FF98;
  --text-dark: #333333;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  font-family: 'Nunito', 'Gamja Flower', sans-serif;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-blue-dream) 0%, var(--morning-mist) 100%);
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 버튼 배치 레이아웃 */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    align-items: center;
    justify-content: center;
}


.sub-buttons {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

/* 새 버튼 스타일 */
.btn-secondary {
    background-color: var(--morning-mist);
    border: 2px solid var(--sky-blue-dream);
    padding: 10px 15px;
    font-size: 1rem;
    border-radius: 15px;
    color: var(--text-dark);
    cursor: pointer;
    font-family: 'Gamja Flower', cursive;
    flex: 1;
    max-width: 120px;
}

/* 랭킹 팝업(모달) 스타일 */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7); /* 배경을 조금 더 어둡게 하면 글자가 잘 보입니다 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* ⬅️ 1000보다 높은 숫자로 변경 (2000 이상 추천) */
}


.modal.hidden {
    display: none !important;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 20px;
    width: 80%;
    max-width: 300px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#modal-leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

#modal-leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed #ddd;
    font-family: 'Gamja Flower', cursive;
    font-size: 1.2rem;
}

.game-container {
  width: 100%;
  height: 100%;
  max-width: 480px;
  position: relative;
  background: transparent;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0,0,0,0.1);
  cursor: pointer;
}

#game-world {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* --- UI Elements --- */

.score-display {
  position: absolute;
  top: 8%; /* 위치 살짝 조정 */
  left: 50%;
  transform: translateX(-50%);
  font-size: 5rem; /* 3rem -> 5rem으로 확대 */
  font-weight: bold;
  color: var(--golden-sun);
  text-shadow: 3px 3px 0px rgba(255, 255, 255, 1), 0 0 10px rgba(255, 215, 0, 0.5);
  font-family: 'Gamja Flower', cursive;
  z-index: 10;
  pointer-events: none;
  transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 점수 획득 시 글자 커지는 효과 */
.score-pop {
    transform: translateX(-50%) scale(1.3);
    color: #fff;
}


/* 모든 화면 레이어 공통 */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex; /* !important 제거 */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000; /* 아주 높게 설정 */
  text-align: center;
  /* 애니메이션 관련 속성 모두 제거 */
  transition: none !important; 
}

/* 가장 강력한 숨김 규칙 (맨 아래에 배치) */
.hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* 게임 오버 화면 내 요소들 정렬 */
#game-over-screen {
    z-index: 1001;
}

.title {
  font-size: 2.5rem;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  margin-bottom: 2rem;
  background-color: var(--sky-blue-dream);
  padding: 10px 20px;
  border-radius: 20px;
  font-family: 'Gamja Flower', cursive;
}

.score-result {
    font-size: 2rem;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
    font-family: 'Gamja Flower', cursive;
}

.btn-primary {
  background-color: var(--minty-fresh);
  border: none;
  padding: 15px 40px;
  font-size: 1.5rem;
  border-radius: 50px;
  color: var(--text-dark);
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: transform 0.1s;
  font-family: 'Gamja Flower', cursive;
}

.btn-primary:active {
  transform: scale(0.95);
}

.ad-placeholder-text {
    margin-top: 30px;
    color: #666;
    font-size: 0.8rem;
}

/* --- Game Objects --- */

/* Bird */
.bird {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 5;
    /* Transformation handled in JS */
}

.bird-body {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.eye {
    position: absolute;
    top: 10px;
    width: 4px;
    height: 4px;
    background: #333;
    border-radius: 50%;
}
.eye.left { left: 8px; }
.eye.right { right: 8px; }

.blush {
    position: absolute;
    top: 18px;
    left: 16px;
    width: 8px;
    height: 4px;
    background: #ffb7b2;
    border-radius: 50%;
}

.fluff-1 { position: absolute; top: -10px; left: 5px; width: 20px; height: 20px; background: #fff; border-radius: 50%; }
.fluff-2 { position: absolute; top: -5px; left: 20px; width: 15px; height: 15px; background: #fff; border-radius: 50%; }

/* Obstacles */
.obstacle {
    position: absolute;
    width: 60px;
    background: linear-gradient(to bottom, #dcdcdc, #a9a9a9);
    box-shadow: 0 5px 5px rgba(0,0,0,0.2);
}

.obstacle.top {
    top: 0;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

.obstacle.bottom {
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    /* Height and top set in JS */
}

.obstacle-detail {
    position: absolute;
    width: 40px;
    height: 10px;
    background: rgba(0,0,0,0.1);
    border-radius: 5px;
}
.obstacle.top .obstacle-detail { bottom: 10px; left: 10px; }
.obstacle.bottom .obstacle-detail { top: 10px; left: 10px; }

/* 리더보드 스타일 */
.leaderboard-container {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    width: 200px;
    font-family: 'Gamja Flower', cursive;
    text-align: center;
}
.leaderboard-container h3 { color: #555; margin-bottom: 5px; border-bottom: 2px solid var(--sky-blue-dream); }
#leaderboard-list { list-style: none; padding: 0; }
#leaderboard-list li { display: flex; justify-content: space-between; padding: 5px 0; font-size: 1.1rem; color: #444; }

/* 등록 폼 스타일 */
.registration-form {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#nickname-input {
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--sky-blue-dream);
    text-align: center;
    font-family: 'Gamja Flower', cursive;
    font-size: 1.2rem;
}
.btn-small {
    background: var(--golden-sun);
    border: none;
    padding: 8px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Gamja Flower', cursive;
    font-weight: bold;
}
.hidden { display: none !important; }


/* Bottom Ad Banner */
.ad-banner {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    height: 50px;
    background-color: #eee;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: #999;
    z-index: 100;
}
