:root {
  --pink: #ff7eb3;
  --pink-2: #ffb3d1;
  --pink-soft: #ffe4ef;
  --blue: #6ec6ff;
  --blue-2: #b7e3ff;
  --lav: #c9b8ff;
  --yellow: #ffd76a;
  --mint: #7fe0c0;
  --ink: #4a3b5c;
  --ink-2: #7d6d8f;
  --card: #fffdf9;
  --line: #f1e3ee;
  --bg-top: #dff1ff;
  --bg-bottom: #ffe9f3;
  --shadow: 0 6px 18px rgba(170, 120, 170, 0.18);
  --radius: 20px;
  --tabbar-h: 74px;
  --font-cute: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --font-body: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, #f3ecff 45%, var(--bg-bottom) 100%) fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { max-width: 100%; }
a { color: #d2558f; }
.hidden { display: none !important; }

/* ---------- 공통 컴포넌트 ---------- */
.cute { font-family: var(--font-cute); font-weight: 400; letter-spacing: -0.2px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid #fff;
  padding: 16px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 20px; border-radius: 999px;
  font-family: var(--font-cute); font-size: 18px;
  color: #fff; background: linear-gradient(180deg, #ff9cc6, var(--pink));
  box-shadow: 0 5px 0 #e0609a, 0 8px 18px rgba(255, 110, 170, 0.35);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #e0609a; }
.btn:disabled { filter: grayscale(.6); opacity: .6; }
.btn.blue { background: linear-gradient(180deg, #9cd8ff, #5ab8f5); box-shadow: 0 5px 0 #3f97d1, 0 8px 18px rgba(90, 184, 245, .35); }
.btn.yellow { color: #6b4a00; background: linear-gradient(180deg, #ffe58f, #ffc93c); box-shadow: 0 5px 0 #e0a51a, 0 8px 18px rgba(255, 200, 60, .35); }
.btn.ghost { color: var(--ink); background: #fff; box-shadow: 0 4px 0 #ecd9e6; }
.btn.small { min-height: 38px; font-size: 15px; padding: 0 14px; }
.btn.block { width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 700; background: var(--pink-soft); color: #c4407f;
}
.chip.blue { background: #e1f3ff; color: #2d84c2; }
.chip.mint { background: #defaf0; color: #1f9c74; }
.chip.gray { background: #f0ecf3; color: var(--ink-2); }
.chip.yellow { background: #fff4cc; color: #9a6b00; }
.field { display: block; margin: 12px 0; }
.field span { display: block; font-weight: 700; font-size: 14px; margin: 0 0 6px 4px; color: var(--ink-2); }
.input {
  width: 100%; height: 52px; border-radius: 16px; border: 2px solid var(--line); background: #fff;
  padding: 0 16px; font-size: 18px; outline: none;
}
.input:focus { border-color: var(--pink-2); box-shadow: 0 0 0 4px var(--pink-soft); }
.muted { color: var(--ink-2); font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }

/* ---------- 레이아웃 ---------- */
#app { max-width: 520px; margin: 0 auto; min-height: 100%; position: relative; }
.screen { padding: 14px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
.screen.full { padding-bottom: 32px; }
.view { display: none; }
.view.active { display: block; animation: pop .25s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.logo {
  font-family: var(--font-cute); font-size: 44px; line-height: 1.05; text-align: center; margin: 8px 0 4px;
  background: linear-gradient(90deg, #ff6fae 0%, #ff8fc0 45%, #59b7ff 55%, #4aa3f0 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 6px 10px rgba(255, 120, 180, .3));
}
.ribbon {
  display: block; width: fit-content; margin: 4px auto 14px; padding: 6px 16px; border-radius: 12px;
  background: #fff6e6; border: 2px solid #ffe2b8; font-size: 14px; font-weight: 700; color: #a06a2c;
}

/* 하단 탭바 */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom)); width: min(500px, calc(100% - 20px));
  height: var(--tabbar-h); background: rgba(255, 253, 249, .96); backdrop-filter: blur(8px);
  border-radius: 26px; box-shadow: 0 8px 24px rgba(150, 100, 160, .22); border: 2px solid #fff;
  display: grid; grid-template-columns: repeat(4, 1fr); z-index: 900;
}
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; font-weight: 700; color: var(--ink-2); position: relative; }
.tabbar .ico { font-size: 26px; line-height: 1; transition: transform .15s; }
.tabbar button.active { color: #e0508f; }
.tabbar button.active .ico { transform: translateY(-3px) scale(1.12); }
.tabbar .dot { position: absolute; top: 10px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ff4d6d; color: #fff; font-size: 11px; display: grid; place-items: center; }

/* ---------- 온보딩 ---------- */
.hero-char { width: 150px; height: 150px; margin: 0 auto; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-2deg); } }
.steps { display: flex; justify-content: center; gap: 6px; margin: 6px 0 14px; }
.steps i { width: 8px; height: 8px; border-radius: 4px; background: #e9d8e5; }
.steps i.on { width: 22px; background: var(--pink); }
.perm-item { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: #fff; border: 2px solid var(--line); }
.perm-item .big { font-size: 30px; }
.perm-item.ok { border-color: var(--mint); background: #f2fffa; }
.char-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.char-opt { aspect-ratio: 1; border-radius: 18px; background: #fff; border: 3px solid var(--line); padding: 4px; }
.char-opt.on { border-color: var(--pink); background: var(--pink-soft); transform: scale(1.04); }
.char-opt svg, .char-opt img { width: 100%; height: 100%; display: block; }

/* ---------- 아바타 ---------- */
.avatar { width: 56px; height: 56px; border-radius: 50%; background: #fff; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(150, 100, 160, .25); overflow: hidden; flex: none; }
.avatar svg, .avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; border-width: 2px; }
.avatar.lg { width: 84px; height: 84px; }

/* ---------- 홈 ---------- */
.me-card { display: flex; align-items: center; gap: 14px; }
.progress { height: 14px; border-radius: 7px; background: #f6e7f0; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #ff9cc6, #ff6fae); border-radius: 7px; transition: width .4s; }
.journey { display: flex; align-items: center; gap: 12px; }
.journey .flag { font-size: 30px; }
.toggle { position: relative; width: 52px; height: 30px; border-radius: 15px; background: #e8dbe6; transition: background .2s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.15); transition: left .2s; }
.toggle.on { background: var(--pink); }
.toggle.on::after { left: 25px; }
.notice { background: #fff8d9; border: 2px dashed #ffd76a; border-radius: 16px; padding: 12px 14px; font-weight: 700; }
.gift-banner { background: linear-gradient(135deg, #fff2f8, #fff9e6); border: 2px solid #ffd1e4; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid .ph { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #f6eef4; position: relative; }
.photo-grid .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .ph .tag { position: absolute; left: 4px; top: 4px; font-size: 11px; padding: 2px 6px; border-radius: 8px; background: rgba(255,255,255,.9); font-weight: 700; }
.section-title { font-family: var(--font-cute); font-size: 21px; margin: 22px 4px 10px; display: flex; align-items: center; justify-content: space-between; }

/* ---------- 미션 ---------- */
.mission { display: flex; gap: 12px; align-items: center; position: relative; overflow: hidden; }
.mission + .mission { margin-top: 12px; }
.mission .badge {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; flex: none;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.08);
}
.mission h3 { margin: 0 0 4px; font-family: var(--font-cute); font-weight: 400; font-size: 19px; }
.mission .meta { display: flex; flex-wrap: wrap; gap: 4px; }
.mission.done::after { content: '완료!'; position: absolute; right: -28px; top: 12px; transform: rotate(35deg); background: var(--mint); color: #fff; font-weight: 800; font-size: 12px; padding: 3px 34px; }
.team-code { font-family: var(--font-cute); font-size: 44px; letter-spacing: 10px; text-align: center; color: #e0508f; background: var(--pink-soft); border-radius: 18px; padding: 8px 0 4px; }
.members { display: flex; flex-wrap: wrap; gap: 8px; }
.member { display: flex; flex-direction: column; align-items: center; width: 64px; font-size: 12px; font-weight: 700; text-align: center; }
.member .avatar { margin-bottom: 3px; }
.slot-empty { width: 52px; height: 52px; border-radius: 50%; border: 3px dashed #e7d3e2; display: grid; place-items: center; color: #d9bfd2; font-size: 22px; margin-bottom: 3px; }

/* ---------- 시트/모달 ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 1500; background: rgba(74, 59, 92, .35); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: var(--card); border-radius: 26px 26px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); animation: up .25s ease; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: #ead9e5; margin: 4px auto 12px; }
.modal-wrap { position: fixed; inset: 0; z-index: 1600; background: rgba(74, 59, 92, .45); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal { width: min(400px, 100%); background: var(--card); border-radius: 26px; padding: 22px 18px 18px; text-align: center; box-shadow: 0 16px 40px rgba(80, 40, 90, .35); border: 3px solid #fff; animation: boing .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes boing { from { transform: scale(.6); opacity: 0; } }
.modal .big-emoji { font-size: 60px; line-height: 1; margin-bottom: 8px; }
.surprise { background: linear-gradient(160deg, #fff6fb, #eef8ff); }
.surprise h2 { font-family: var(--font-cute); font-weight: 400; font-size: 26px; margin: 4px 0 8px; color: #e0508f; }
.shake { animation: boing .45s cubic-bezier(.2, 1.6, .4, 1), shake .6s .45s; }
@keyframes shake { 20%, 60% { transform: rotate(-3deg); } 40%, 80% { transform: rotate(3deg); } }
.lightbox { position: fixed; inset: 0; z-index: 1700; background: rgba(20, 10, 30, .92); display: grid; place-items: center; padding: 12px; }
.lightbox img { max-height: 82vh; border-radius: 12px; }
.lightbox .row { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 0; right: 0; justify-content: center; }

/* 업로드 진행률 */
.upload-box { text-align: center; }
.upload-bar { height: 18px; border-radius: 9px; background: #f3e4ee; overflow: hidden; margin: 12px 0 6px; }
.upload-bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, #ff8fc0 0 12px, #ff74b0 12px 24px); transition: width .2s; }

/* 토스트 */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2000; background: #4a3b5c; color: #fff; padding: 12px 18px; border-radius: 16px; font-weight: 700; max-width: calc(100% - 40px); box-shadow: 0 8px 20px rgba(0,0,0,.2); animation: up .2s; }

/* ---------- 지도 ---------- */
.map-wrap { position: relative; margin: 0 -16px; }
#map { height: calc(100vh - 230px); height: calc(100dvh - 230px); min-height: 360px; border-radius: 0; background: #e8f4ff; }
.zone-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.zone-tabs::-webkit-scrollbar { display: none; }
.zone-tabs button { flex: none; padding: 8px 14px; border-radius: 999px; background: #fff; font-weight: 800; font-size: 14px; box-shadow: 0 3px 0 #ecd9e6; white-space: nowrap; }
.zone-tabs button.on { background: var(--pink); color: #fff; box-shadow: 0 3px 0 #e0609a; }
.map-fabs { position: absolute; right: 12px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 500; }
.fab { width: 50px; height: 50px; border-radius: 50%; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.18); font-size: 22px; display: grid; place-items: center; }
.map-info { position: absolute; left: 12px; top: 12px; right: 12px; z-index: 500; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.map-info > * { pointer-events: auto; background: rgba(255,255,255,.95); box-shadow: 0 3px 8px rgba(0,0,0,.12); }
.pin { display: grid; place-items: center; }
.pin .bubble { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.3); background: #fff; }
.pin .bubble svg, .pin .bubble img { width: 100%; height: 100%; display: block; object-fit: cover; }
.pin.me .bubble { border-color: var(--pink); width: 46px; height: 46px; }
.pin.hiddenme .bubble { opacity: .55; }
.pin .name { margin-top: 2px; font-size: 11px; font-weight: 800; background: #fff; padding: 1px 6px; border-radius: 8px; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.pin.stale .bubble { filter: grayscale(.8); opacity: .7; }
.mpin { font-size: 22px; width: 42px; height: 42px; border-radius: 14px 14px 14px 4px; display: grid; place-items: center; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.3); transform: rotate(-4deg); }
.mpin.done { filter: grayscale(.4); opacity: .75; }
.leaflet-container { font-family: var(--font-body); }
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; }

/* 식당 */
.place h3 { margin: 0 0 4px; font-family: var(--font-cute); font-weight: 400; font-size: 19px; }
.place + .place { margin-top: 12px; }
.filter-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
.filter-row button { flex: none; padding: 6px 12px; border-radius: 999px; background: #fff; font-weight: 700; font-size: 14px; border: 2px solid var(--line); }
.filter-row button.on { border-color: var(--pink); color: #e0508f; background: var(--pink-soft); }

/* 글자판 (6인 미션용) */
.letter-board { position: fixed; inset: 0; z-index: 1800; display: grid; place-items: center; background: #fff; font-family: var(--font-cute); font-size: 70vmin; color: #ff5fa2; line-height: 1; }
.letter-board small { position: absolute; bottom: 24px; font-size: 16px; color: var(--ink-2); font-family: var(--font-body); }

/* 초기 로딩 */
.boot { min-height: 100vh; display: grid; place-items: center; text-align: center; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 5px solid var(--pink-soft); border-top-color: var(--pink); animation: spin 1s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
