/* 가족코인 — 둥글고 밝은 가족 앱(사용자: "귀엽게 만들면 좋을 것 같아"). */

:root {
  --cream: #fff4e0;
  --paper: #fffdf8;
  --ink: #4a3426;
  --muted: #9b8576;
  --coin: #ffc93c;
  --coin-deep: #f2a900;
  --coral: #ff8a65;
  --mint: #5cc9a7;
  --sky: #7ec8e3;
  --lilac: #b39ddb;
  --pink: #ffb5c2;
  --line: #f1e3cc;
  --shadow: 0 6px 0 #f0d9b5, 0 10px 24px rgba(120, 80, 30, 0.08);
  --radius: 22px;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Gowun Dodum', system-ui, sans-serif;
}

body {
  /* 바탕에 옅은 물방울 무늬. */
  background-image: radial-gradient(#ffe8c2 1.6px, transparent 1.6px);
  background-size: 22px 22px;
}

h1, h2, h3, .jua, button, .btn { font-family: 'Jua', system-ui, sans-serif; font-weight: normal; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

/* ---------- 공통 ---------- */

.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 14px 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 1.12rem;
  color: #fff;
  background: var(--coral);
  box-shadow: 0 4px 0 #e0674a;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
  text-decoration: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #e0674a; }
.btn.mint { background: var(--mint); box-shadow: 0 4px 0 #3fa585; }
.btn.sky { background: var(--sky); box-shadow: 0 4px 0 #57a6c2; }
.btn.coin { background: var(--coin); color: var(--ink); box-shadow: 0 4px 0 var(--coin-deep); }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: 0 4px 0 var(--line); }
.btn.small { padding: 8px 14px; font-size: 0.95rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

input, select, textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1.05rem;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus { border-color: var(--coin); }
label { display: block; margin: 12px 0 6px; font-size: 0.92rem; color: var(--muted); }

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small-text { font-size: 0.86rem; }
.spacer { height: 10px; }

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: #fff1d6;
  color: #a06b00;
}
.chip.mint { background: #dcf5ec; color: #2c8a6b; }
.chip.coral { background: #ffe3da; color: #c4502e; }
.chip.sky { background: #def1f8; color: #2f86a6; }

/* ---------- 머리 ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.top .title { font-family: 'Jua'; font-size: 1.3rem; flex: 1; }
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  flex: none;
}
.avatar.big { width: 84px; height: 84px; font-size: 50px; }
.iconbtn {
  border: none;
  background: #fff;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 20px;
  box-shadow: 0 3px 0 var(--line);
  cursor: pointer;
  flex: none;
}

/* ---------- 코인 지갑 ---------- */

.wallet {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #ffd96a, #ffbf3c);
  color: var(--ink);
  border-radius: 28px;
  padding: 20px;
  box-shadow: 0 6px 0 var(--coin-deep), 0 14px 30px rgba(242, 169, 0, 0.25);
  margin: 12px 0 18px;
}
.wallet .label { font-family: 'Jua'; opacity: 0.8; }
.wallet .amount {
  font-family: 'Jua';
  font-size: 3.2rem;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wallet .mascot {
  position: absolute;
  right: -6px;
  bottom: -10px;
  width: 118px;
  animation: bob 2.6s ease-in-out infinite;
}
.wallet .streak { margin-top: 6px; font-family: 'Jua'; }

.coin-ic {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff2b0 0 18%, var(--coin) 19% 70%, var(--coin-deep) 71%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
  vertical-align: -0.12em;
}

@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
.pop { animation: pop 0.45s ease-out; }

/* ---------- 미션 ---------- */

.mission {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.mission .emoji {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 32px;
  background: #fff4dc;
  flex: none;
}
.mission .body { flex: 1; min-width: 0; }
.mission .name { font-family: 'Jua'; font-size: 1.15rem; }
.mission .meta { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.mission.done { opacity: 0.65; }
.mission.done .emoji { background: #dcf5ec; }

/* ---------- 상점 ---------- */

.shop { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.reward {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 12px;
  text-align: center;
}
.reward .emoji { font-size: 44px; }
.reward .name { font-family: 'Jua'; font-size: 1.05rem; margin: 4px 0; min-height: 2.4em; }
.progress {
  height: 10px;
  border-radius: 999px;
  background: #f6ead6;
  overflow: hidden;
  margin: 8px 0;
}
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--coin), var(--coral)); border-radius: 999px; }

/* ---------- 아래 탭 ---------- */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, 0.96);
  border-top: 2px solid var(--line);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.tabs .inner { display: flex; max-width: 560px; width: 100%; }
.tabs a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-family: 'Jua';
  font-size: 0.85rem;
  padding: 4px 0;
  border-radius: 16px;
  position: relative;
}
.tabs a .ic { display: block; font-size: 24px; line-height: 1.2; }
.tabs a.on { color: var(--ink); background: #fff1d6; }
.tabs .badge {
  position: absolute;
  top: 0;
  right: 22%;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--coral);
  color: #fff;
  font-size: 0.72rem;
  line-height: 18px;
}

/* ---------- 첫 화면 ---------- */

.hero { text-align: center; padding-top: 18px; }
.hero img { width: 180px; animation: bob 2.6s ease-in-out infinite; }
.hero h1 { font-size: 2.3rem; margin: 6px 0 2px; }
.who-btns { display: grid; gap: 14px; margin-top: 26px; }
.who-btns .btn { padding: 20px; font-size: 1.35rem; }

/* ---------- 아이 고르기·PIN ---------- */

.kid-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.kid-pick button {
  border: none;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 6px;
  cursor: pointer;
  font-family: 'Jua';
  font-size: 1rem;
  color: var(--ink);
}
.kid-pick .face { font-size: 44px; display: block; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; background: #f1e3cc; }
.pin-dots i.on { background: var(--coral); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto; }
.keypad button {
  border: none;
  background: var(--paper);
  border-radius: 20px;
  box-shadow: 0 4px 0 var(--line);
  font-family: 'Jua';
  font-size: 1.8rem;
  padding: 14px 0;
  color: var(--ink);
  cursor: pointer;
}
.keypad button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- 고르기(이모지·색·요일) ---------- */

.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.picker button {
  border: 2px solid transparent;
  background: #fff;
  border-radius: 14px;
  min-width: 44px;
  height: 44px;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--line);
  font-family: 'Jua';
  color: var(--ink);
}
.picker button.on { border-color: var(--coral); background: #fff1ea; }
.picker.text button { font-size: 0.95rem; padding: 0 12px; }
/* 아이 카드 단추 넷. 좁은 폰에서도 글자가 두 줄로 깨지지 않게 칸을 나눈다. */
.kid-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.kid-actions .btn { padding: 8px 4px; font-size: 0.86rem; white-space: nowrap; gap: 3px; }
.coin-picker { background: #fff7e3; border-radius: 20px; padding: 12px; }
.coin-row { display: flex; align-items: center; gap: 10px; }
.coin-step {
  flex: none;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 0 var(--line);
  font-family: 'Jua';
  font-size: 1.8rem;
  color: var(--ink);
  cursor: pointer;
}
.coin-step:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.coin-big { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 2.2rem; }
.coin-num {
  width: 4.2ch;
  border: none;
  background: transparent;
  font-family: 'Jua';
  font-size: 2.6rem;
  text-align: center;
  padding: 0;
}
.coin-presets { justify-content: center; margin-top: 10px; }
.coin-presets button { font-size: 1rem; }
.picker.colors button { width: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.picker.colors .dot { width: 28px; height: 28px; border-radius: 50%; display: block; }

.toggle { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 4px; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #eadbc3; border-radius: 30px; transition: 0.2s; }
.switch span::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + span { background: var(--mint); }
.switch input:checked + span::before { transform: translateX(22px); }

/* ---------- 승인 ---------- */

.review { display: flex; gap: 12px; align-items: flex-start; }
.review .photo { width: 100%; border-radius: 16px; margin-top: 10px; max-height: 320px; object-fit: cover; }
.review-actions { display: flex; gap: 10px; margin-top: 12px; }
.review-actions .btn { flex: 1; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 2px dashed var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.plus { color: #2c8a6b; font-family: 'Jua'; }
.minus { color: #c4502e; font-family: 'Jua'; }

.empty { text-align: center; padding: 28px 10px; color: var(--muted); }
.empty img { width: 110px; opacity: 0.9; }

.sheet-bg { position: fixed; inset: 0; background: rgba(74, 52, 38, 0.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--paper);
  width: 100%;
  max-width: 560px;
  border-radius: 28px 28px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 92vh;
  overflow: auto;
  animation: up 0.22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 4px 0 6px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-family: 'Jua';
  opacity: 0;
  transition: 0.25s;
  z-index: 40;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; width: 100%; height: 100%; }

.code-box {
  font-family: 'Jua';
  font-size: 2rem;
  letter-spacing: 6px;
  text-align: center;
  background: #fff4dc;
  border-radius: 18px;
  padding: 12px;
  margin: 8px 0;
}
.code-input { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-family: 'Jua'; font-size: 1.6rem; }
