/* --- 1. 기본 설정 & 폰트 --- */
:root {
  --primary-pink: #ffb7c5;
  --dark-pink: #ff8fab;
  --primary-blue: #a2d2ff;
  --soft-yellow: #fff4bd;
  --mint: #b9fbc0;
  --text-color: #5a4a42;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Jua', 'Gaegu', sans-serif;
  background-color: #fff9f0;
  color: var(--text-color);
  overflow-x: hidden;
  line-height: 1.2;
}

.game-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

/* --- 2. 상단 헤더 --- */
#game-header {
  width: 100%;
  max-width: 850px;
  background: white;
  border-radius: 20px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 5px 0 #eee;
  margin-bottom: 15px;
  border: 4px solid var(--primary-blue);
  gap: 5px;
}

.header-left { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.logo-icon { font-size: 22px; }
.title-group h1 { font-size: 16px; color: var(--dark-pink); margin: 0; white-space: nowrap; }
#level-display { font-size: 11px; color: #aaa; }

.stats-group { display: flex; gap: 10px; align-items: center; flex-grow: 1; justify-content: center; min-width: 0; }
.stat-item { display: flex; flex-direction: column; align-items: center; min-width: 45px; }
.stat-item .label { font-size: 11px; color: #888; white-space: nowrap; }
.stat-item span:last-child { font-size: 17px; font-weight: bold; white-space: nowrap; }

.actions-group { display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; align-items: center; gap: 5px; flex-shrink: 0; }

/* --- 3. 버튼 디자인 --- */
button {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Jua', sans-serif;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}
button:active { transform: scale(0.95); }

#shuffle-btn { background: var(--soft-yellow); width: 36px; height: 36px; font-size: 15px; border-bottom: 3px solid #f0e080; }
#time-item-btn { background: var(--mint); height: 36px; padding: 0 8px; border-bottom: 3px solid #98db9c; gap: 3px; font-size: 12px; white-space: nowrap; }

/* 메인 큰 버튼들 */
.pulse-btn, .retry-btn, .next-btn, .share-btn {
  padding: 8px 15px;
  font-size: 14px;
  border-radius: 50px;
  color: white;
  width: fit-content;
}
.pulse-btn { background: var(--dark-pink); border-bottom: 5px solid #e67a94; animation: pulse 2s infinite; }
.retry-btn { background: #adb5bd; border-bottom: 5px solid #868e96; }
.next-btn { background: var(--mint); color: #5a4a42; border-bottom: 5px solid #98db9c; min-width: 180px; }
.share-btn { background: var(--primary-blue); border-bottom: 4px solid #72aee6; margin: 0; min-width: 160px; height: 50px; }

.description { 
  font-size: clamp(16px, 4vw, 20px); 
  margin-bottom: 25px !important; /* <--- 25px 늘리고 !important를 추가했습니다. */
  line-height: 1.4; 
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* --- 4. 게임 종료 화면: 가로 배치 설정들 --- */


/* 상단 행: 최종 점수 + 공유하기 */
.top-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 360px;
  margin: 7px auto 7px auto; 
}

/* 하단 행: 점수 등록 + 다시 하기 */
.button-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
    margin: 7px auto 7px auto; 
}
.button-row button { flex: 1; height: 50px; margin: 0; }

/* --- 5. 게임판 (그리드) --- */
#game-area {
  position: relative;
  width: 100%;
  max-width: 850px;
  background: #ffffff;
  border-radius: 25px;
  border: 6px solid #ffe5ec;
  padding: 8px;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#game-grid { display: grid; gap: 5px; width: 100%; }
.tile {
  aspect-ratio: 1 / 1;
  background: #fff;
  border: 2px solid #f0f0f0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.2rem, 5vw, 2.2rem);
  cursor: pointer;
  box-shadow: 0 3px 0 #eee;
  user-select: none;
}
.tile.selected { background: var(--primary-blue); border-color: #72aee6; }
.tile.matched { animation: matchPop 0.4s forwards; }
.tile.empty { visibility: hidden; }

@keyframes matchPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); background: var(--mint); }
  100% { transform: scale(0); opacity: 0; }
}

/* --- 6. 오버레이 화면 --- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.98);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  padding: 15px;
}
.overlay-content {
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.main-title { font-size: 32px; color: var(--dark-pink); margin-bottom: 25px; }

.title-bad { 
  color: #ff6b6b; 
  font-size: 22px; 
  margin-bottom: 5px !important; /* <--- 5px로 늘리고, 확실히 적용되게 !important를 붙였습니다. */
}

.score-card {
  background: #fff0f6;
  padding: 10px 15px;
  border-radius: 15px;
  border: 2px dashed var(--dark-pink);
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 50px;
  min-width: 120px;
}
.score-card .label { font-size: 12px; margin-bottom: 2px; }

/* --- 7. 입력창 및 리더보드 --- */
#submit-area { width: 100%; max-width: 320px; margin: 5px auto; }
#nickname-input {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid var(--dark-pink);
  text-align: center;
  font-family: 'Jua', sans-serif;
  font-size: 13px;
  outline: none;
}
#leaderboard-area {
  width: 100%;
  max-width: 320px;
  background: #f8f9fa;
  padding: 12px;
  border-radius: 12px;
  margin-top: 3px;
}

/* --- 8. 연결 선 --- */
#connection-svg {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
  display: none;
}
#connection-line { stroke: var(--dark-pink); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }

/* --- 9. 모바일 최적화 --- */
@media (max-width: 450px) {
  #game-header { padding: 8px 6px; }
  .logo-icon { display: none; }
  .stats-group { gap: 6px; }
  .stat-item { min-width: 40px; }
  .top-row { flex-direction: row; gap: 8px; }
  .score-card { min-width: 100px; padding: 5px 10px; }
  .share-btn { min-width: 140px; font-size: 14px; }
}

