/* ===== 기본 설정 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --pink:   #FF6EB4;
  --purple: #A855F7;
  --yellow: #FDE68A;
  --green:  #86EFAC;
  --blue:   #93C5FD;
  --orange: #FDBA74;
  --bg:     #FFF9F0;
  --text:   #3B2D6B;
  --card:   #FFFFFF;
  --radius: 20px;
  --shadow: 0 4px 20px rgba(168,85,247,.15);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', 'Apple SD Gothic Neo', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== 히어로 ===== */
.hero {
  background: linear-gradient(135deg, #C084FC 0%, #FB7185 50%, #FBBF24 100%);
  color: white;
  text-align: center;
  padding: 2.5rem 1rem 0;
  position: relative;
  overflow: hidden;
}
.hero h1 { font-size: clamp(2rem, 6vw, 3.5rem); font-weight: 900; text-shadow: 2px 3px 0 rgba(0,0,0,.15); }
.hero-sub { font-size: clamp(1rem, 3vw, 1.4rem); margin-top: .4rem; opacity: .95; }

.hero-stars { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.star { position: absolute; font-size: 1.8rem; animation: float 4s ease-in-out infinite; }
.s1 { top: 10%; left: 8%;  animation-delay: 0s; }
.s2 { top: 20%; right: 10%; animation-delay: .8s; }
.s3 { top: 60%; left: 15%; animation-delay: 1.6s; }
.s4 { top: 5%;  left: 50%; animation-delay: 2.2s; }
.s5 { top: 50%; right: 5%; animation-delay: .4s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%       { transform: translateY(-12px) rotate(15deg); }
}

/* ===== 탭 네비 ===== */
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  margin-top: 1.5rem;
  padding: .5rem;
}
.tab-btn {
  background: rgba(255,255,255,.25);
  color: white;
  border: 2px solid rgba(255,255,255,.6);
  border-radius: 50px;
  padding: .65rem 1.2rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  transition: all .2s;
  backdrop-filter: blur(4px);
}
.tab-btn:hover, .tab-btn.active {
  background: white;
  color: var(--purple);
  border-color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

/* ===== 컨테이너 ===== */
.container { max-width: 800px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.tab-content { display: block; }
.tab-content.hidden { display: none !important; }

h2 { font-size: clamp(1.4rem, 4vw, 2rem); color: var(--purple); margin-bottom: .4rem; }
.desc { color: #6B7280; font-size: 1rem; margin-bottom: 1.2rem; }

/* ===== 버튼 ===== */
.btn-primary {
  display: inline-block;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: white;
  border: none;
  border-radius: 50px;
  padding: .8rem 2rem;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
  transition: all .2s;
  box-shadow: 0 4px 12px rgba(168,85,247,.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(168,85,247,.45); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-block;
  background: white;
  color: var(--purple);
  border: 2px solid var(--purple);
  border-radius: 50px;
  padding: .65rem 1.4rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  transition: all .2s;
}
.btn-secondary:hover:not(:disabled) { background: var(--purple); color: white; }
.btn-secondary:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 게임 ===== */
.game-area { background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.game-hud { display: flex; justify-content: space-around; margin-bottom: 1rem; background: var(--yellow); border-radius: 12px; padding: .6rem 1rem; font-size: 1.1rem; }
.hud-item strong { font-size: 1.3rem; color: var(--purple); }

.game-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-width: 400px;
  margin: 0 auto;
  background: linear-gradient(135deg, #EDE9FE, #FCE7F3);
  border-radius: var(--radius);
  overflow: hidden;
}
.game-ready { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 1rem; font-size: 1.3rem; }

.star-target {
  position: absolute;
  font-size: 2.5rem;
  cursor: pointer;
  user-select: none;
  transition: transform .1s;
  animation: pop-in .15s ease;
  min-width: 52px; min-height: 52px;
  display: flex; align-items: center; justify-content: center;
}
.star-target:active { transform: scale(.85); }
@keyframes pop-in { from { transform: scale(0); } to { transform: scale(1); } }

.game-result { text-align: center; padding: 1.5rem; }
.result-emoji { font-size: 4rem; }
.result-msg { font-size: 1.4rem; font-weight: 700; margin: .5rem 0 1rem; }

/* 카드 게임 */
.memory-hud { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; font-size: 1rem; }
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .6rem;
  max-width: 400px;
}
.mem-card {
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  border-radius: 12px;
  font-size: 1.8rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform .3s, background .3s;
  min-height: 52px;
  box-shadow: 0 3px 8px rgba(0,0,0,.15);
}
.mem-card .front { display: none; }
.mem-card .back  { display: block; font-size: 1.4rem; color: rgba(255,255,255,.6); }
.mem-card.flipped { background: var(--yellow); transform: rotateY(0); }
.mem-card.flipped .front { display: block; }
.mem-card.flipped .back  { display: none; }
.mem-card.matched { background: var(--green); cursor: default; animation: bounce .4s; }
@keyframes bounce { 0%,100%{transform:scale(1)} 50%{transform:scale(1.15)} }

.win-msg { text-align: center; font-size: 1.4rem; font-weight: 700; color: var(--purple); padding: 1rem; background: var(--yellow); border-radius: var(--radius); margin-top: 1rem; }

/* ===== 퀴즈 ===== */
.quiz-card { background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.quiz-progress { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; font-weight: 700; color: var(--purple); }
.progress-bar { flex: 1; height: 10px; background: #E9D5FF; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--purple), var(--pink)); border-radius: 99px; transition: width .4s; }

.question { font-size: 1.3rem; font-weight: 700; margin-bottom: 1.2rem; line-height: 1.5; }
.choices { display: flex; flex-direction: column; gap: .7rem; }
.choice-btn {
  background: #F3F4F6;
  color: var(--text);
  border: 2px solid #E5E7EB;
  border-radius: 14px;
  padding: .85rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  min-height: 52px;
  transition: all .15s;
}
.choice-btn:hover { background: #EDE9FE; border-color: var(--purple); }
.choice-btn.correct { background: #D1FAE5; border-color: #10B981; color: #065F46; }
.choice-btn.wrong   { background: #FEE2E2; border-color: #EF4444; color: #991B1B; }
.choice-btn:disabled { cursor: default; }

.quiz-feedback { margin-top: 1rem; padding: .8rem 1rem; border-radius: 14px; font-weight: 600; font-size: 1rem; }
.quiz-feedback.correct { background: #D1FAE5; color: #065F46; }
.quiz-feedback.wrong   { background: #FEE2E2; color: #991B1B; }

.quiz-result { text-align: center; background: var(--card); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.quiz-result p { font-size: 1.2rem; margin: .4rem 0; }
#quiz-grade { font-size: 1.4rem; font-weight: 700; color: var(--purple); }

/* ===== 메시지 게시판 ===== */
.msg-form { background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: .5rem; }
.msg-form label { font-weight: 700; color: var(--purple); }
.msg-form input, .msg-form textarea {
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  padding: .75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color .2s;
  min-height: 48px;
}
.msg-form input:focus, .msg-form textarea:focus { outline: none; border-color: var(--purple); }
.msg-form textarea { resize: vertical; min-height: 90px; }
.char-count { font-size: .85rem; color: #9CA3AF; text-align: right; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .3rem; }
.emoji-opt {
  font-size: 1.8rem;
  background: #F3F4F6;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: .3rem .5rem;
  cursor: pointer;
  min-width: 52px; min-height: 52px;
  transition: all .15s;
}
.emoji-opt.selected { border-color: var(--purple); background: #EDE9FE; transform: scale(1.15); }

.msg-board { display: flex; flex-direction: column; gap: .8rem; }
.no-msg { text-align: center; color: #9CA3AF; font-size: 1rem; padding: 2rem; }
.msg-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
  border-left: 5px solid var(--pink);
  display: flex;
  gap: .8rem;
  align-items: flex-start;
  animation: slide-in .3s ease;
}
@keyframes slide-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.msg-emoji { font-size: 2.2rem; flex-shrink: 0; }
.msg-body { flex: 1; }
.msg-author { font-weight: 700; color: var(--purple); font-size: 1rem; }
.msg-date { font-size: .8rem; color: #9CA3AF; }
.msg-text { margin-top: .3rem; font-size: 1rem; line-height: 1.55; word-break: break-word; }

/* ===== 동화 ===== */
.story-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1rem; font-size: 1.1rem; font-weight: 700; color: var(--purple); }
.story-book {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  min-height: 300px;
}
.story-page { animation: fade-page .4s ease; }
@keyframes fade-page { from { opacity: 0; } to { opacity: 1; } }
.story-art { text-align: center; font-size: 6rem; margin-bottom: 1.2rem; line-height: 1; }
.story-title { font-size: 1.3rem; font-weight: 900; color: var(--purple); margin-bottom: .8rem; text-align: center; }
.story-text { font-size: 1.1rem; line-height: 1.8; color: #374151; }
.story-text p { margin-bottom: .7rem; }
.story-msg { text-align: center; font-size: 1.2rem; font-weight: 700; color: var(--pink); margin-top: 1rem; background: var(--yellow); border-radius: 14px; padding: .8rem; }

/* ===== 푸터 ===== */
.footer { text-align: center; padding: 1.5rem; background: linear-gradient(135deg, #C084FC, #FB7185); color: white; font-weight: 700; font-size: 1rem; margin-top: 2rem; }

/* ===== 공통 ===== */
.hidden { display: none !important; }

/* ===== 반응형 ===== */
@media (max-width: 480px) {
  .memory-board { grid-template-columns: repeat(4, 1fr); gap: .4rem; }
  .mem-card { font-size: 1.4rem; }
  .star-target { font-size: 2rem; }
}
