/* 달빛 약초상 */
@font-face {
  font-family: 'Galmuri11';
  src: url('../assets/font/Galmuri11.woff2') format('woff2');
  font-weight: normal; font-display: swap;
}
@font-face {
  font-family: 'Galmuri11';
  src: url('../assets/font/Galmuri11-Bold.woff2') format('woff2');
  font-weight: bold; font-display: swap;
}

:root {
  --bg: #171226;
  --bg2: #1f1833;
  --card: #251d3d;
  --card2: #2e2450;
  --line: #3d3163;
  --txt: #efe9ff;
  --sub: #a89cc8;
  --gold: #ffd166;
  --accent: #a97fe8;
  --green: #7ee08a;
  --red: #ff7b7b;
  --dirt: #b5843f;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; }
body {
  font-family: 'Galmuri11', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  overscroll-behavior-y: contain;
  user-select: none;
}
img.px { image-rendering: pixelated; }

#app { max-width: 520px; margin: 0 auto; padding: 0 10px 84px; }

/* 헤더 */
header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, #241b45 0%, #1c1535 80%, transparent);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 2px 8px; /* iOS 노치 */
  display: flex; align-items: center; gap: 8px;
}
#shopname {
  font-weight: bold; font-size: 1.05rem; cursor: pointer;
  display: flex; align-items: center; gap: 6px; flex: 1;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
#shopname::before { content: '🌙'; }
.pill {
  background: var(--card2); border: 1px solid var(--line); border-radius: 20px;
  padding: 4px 10px; font-size: .85rem; display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.pill img { width: 14px; height: 14px; }
#gold { color: var(--gold); font-weight: bold; }
#codexpct { color: var(--accent); font-weight: bold; }

#tuthint {
  background: linear-gradient(90deg, #3d2f6b, #2e2450);
  border: 1px solid var(--accent); border-radius: 10px;
  padding: 8px 12px; margin: 4px 0 8px; font-size: .85rem;
  animation: hintglow 2s ease-in-out infinite;
}
@keyframes hintglow { 50% { border-color: #d4bcf7; } }

/* 카드 */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; margin-bottom: 10px;
}
.card h3 { font-size: .95rem; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.sub { color: var(--sub); font-size: .78rem; font-weight: normal; }
.emptymsg { color: var(--sub); font-size: .85rem; text-align: center; padding: 12px 0; }

/* 텃밭 */
.garden-card { padding: 10px; background: linear-gradient(180deg, #223018, #1c2814); border-color: #38502a; }
.garden { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.plot {
  aspect-ratio: 1; border-radius: 10px; border: 2px solid #59431f;
  background: #6e5426 url('../assets/img/dirt.png') center/cover;
  image-rendering: pixelated;
  position: relative; cursor: pointer; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 0; font-family: inherit; color: var(--txt);
}
.plot.empty .plus { color: rgba(255,255,255,.45); font-size: 1.3rem; }
.plot.locked {
  filter: brightness(.55); border-style: dashed; border-color: #8a7340;
}
.plot.locked .price {
  background: rgba(0,0,0,.55); border-radius: 6px; padding: 2px 4px;
  font-size: .62rem; color: var(--gold); filter: brightness(1.6);
}
.plot .crop { width: 68%; height: 68%; object-fit: contain; }
.plot.ready { border-color: var(--gold); box-shadow: 0 0 10px rgba(255, 209, 102, .35); }
.ready-bounce { animation: bounce 1s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-8%) scale(1.06); } }
.readytag {
  position: absolute; top: 3px; right: 4px; color: var(--gold);
  font-size: .7rem; font-weight: bold; text-shadow: 0 0 4px #000;
}
.pbar {
  position: absolute; bottom: 3px; left: 8%; width: 84%; height: 5px;
  background: rgba(0,0,0,.5); border-radius: 3px; overflow: hidden;
}
.pbar.wide { position: static; width: 100%; display: block; margin: 4px 0; }
.pfill { display: block; height: 100%; background: var(--green); border-radius: 3px; transition: width .4s linear; }

.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(169, 127, 232, .7); }
  50% { box-shadow: 0 0 0 7px rgba(169, 127, 232, 0); }
}

/* 가마솥 */
.brewbox {
  display: flex; align-items: center; gap: 12px;
  background: var(--card2); border-radius: 12px; padding: 10px; margin-bottom: 8px;
}
.brewbox.done { border: 1px solid var(--gold); }
.cauldron-wrap { position: relative; flex-shrink: 0; }
.cauldron-img { width: 52px; height: 52px; }
.bubbles { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); font-size: .9rem; animation: floatup 1.6s ease-in-out infinite; }
@keyframes floatup { 50% { transform: translateX(-50%) translateY(-4px); } }
.brewing .cauldron-img { animation: shake 2.4s ease-in-out infinite; }
@keyframes shake { 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }
.brewinfo { flex: 1; min-width: 0; }
.brewlabel { font-size: .9rem; font-weight: bold; margin-bottom: 4px; }
.slotrow { display: flex; gap: 8px; margin-bottom: 6px; }
.slot {
  width: 44px; height: 44px; border-radius: 10px; border: 2px dashed var(--line);
  background: var(--bg2); color: var(--sub); font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-family: inherit;
}
.slot img { width: 30px; height: 30px; }
.brewpreview { font-size: .82rem; color: var(--sub); margin-bottom: 6px; display: flex; align-items: center; gap: 4px; }
.timer { font-size: .75rem; color: var(--sub); }

/* 칩 */
.chiprow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 18px;
  padding: 5px 10px; font-size: .78rem; color: var(--txt); cursor: pointer; font-family: inherit;
}
.chip.gold { border-color: var(--gold); }
.chip b { color: var(--gold); }
.mini { width: 20px; height: 20px; }
.dim { opacity: .45; }

/* 손님 */
.custrow { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.custrow:last-child { border-bottom: none; }
.cust { width: 36px; height: 36px; flex-shrink: 0; }
.walk { animation: bob .7s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.bubble {
  flex: 1; min-width: 0; background: var(--card2); border-radius: 10px;
  padding: 7px 10px; font-size: .8rem; line-height: 1.45;
}
.custname { display: block; color: var(--sub); font-size: .68rem; }
.pay { color: var(--gold); white-space: nowrap; }
.xbtn { background: none; border: none; color: var(--sub); font-size: .9rem; cursor: pointer; padding: 4px; }

/* 원정 */
.expedrow { display: flex; align-items: center; gap: 10px; }
.expedinfo { flex: 1; min-width: 0; font-size: .85rem; line-height: 1.5; }
.match { color: var(--green); font-size: .72rem; }

/* 버튼 */
.btn {
  background: var(--card2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 9px 14px; font-size: .85rem; font-family: inherit;
  cursor: pointer; flex-shrink: 0;
}
.btn.primary { background: linear-gradient(180deg, #7b5cd6, #6348b8); border-color: #9678e8; font-weight: bold; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.dim { opacity: .45; }
.btn:active { transform: scale(.96); }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* 도감 */
.codexbar { height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; margin-bottom: 10px; }
.codexbar div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.codexgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.codexgrid.c3 { grid-template-columns: repeat(3, 1fr); }
.codexcell {
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 4px; text-align: center;
}
.codexcell.found { border-color: #56487f; }
.codexcell.frag { border-color: var(--gold); border-style: dashed; }
.codeximg img { width: 34px; height: 34px; }
.codeximg.sil img { filter: brightness(0) opacity(.5); }
.codexname { font-size: .68rem; margin-top: 4px; word-break: keep-all; }
.codexval { font-size: .64rem; color: var(--gold); }
.herbrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: .85rem; }
.herbrow img { width: 26px; height: 26px; flex-shrink: 0; }

/* 스킬 */
.uprow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.uprow:last-child { border-bottom: none; }
.uprow > img { width: 28px; height: 28px; flex-shrink: 0; }
.upinfo { flex: 1; min-width: 0; font-size: .85rem; }
.lv { color: var(--accent); font-size: .72rem; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: .82rem; color: var(--sub); }
.statgrid b { color: var(--txt); }
.credit { margin-top: 10px; line-height: 1.6; }

/* 시트/모달 */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 6, 20, .6); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.overlay.show { opacity: 1; }
.sheet {
  background: var(--bg2); border: 1px solid var(--line); border-bottom: none;
  border-radius: 18px 18px 0 0; width: 100%; max-width: 520px;
  max-height: 78vh; overflow-y: auto; padding: 16px 14px 24px;
  transform: translateY(30px); transition: transform .2s;
}
.overlay.show .sheet { transform: none; }
.overlay .sheet.center {
  border-radius: 18px; border-bottom: 1px solid var(--line);
  width: calc(100% - 40px); max-width: 380px; margin-bottom: 30vh;
}
.overlay.centered { align-items: center; }
.sheet h3 { margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

.seedrow, .destrow {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; margin-bottom: 7px; cursor: pointer; text-align: left;
  color: var(--txt); font-family: inherit; font-size: .88rem;
}
.seedrow img { width: 30px; height: 30px; flex-shrink: 0; }
.seedinfo { flex: 1; min-width: 0; }
.seedcost { color: var(--gold); font-size: .8rem; flex-shrink: 0; }
.destrow { flex-direction: column; align-items: flex-start; gap: 3px; }
.destname { display: flex; gap: 6px; align-items: baseline; }

.textinput {
  width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; color: var(--txt); font-family: inherit; font-size: 1rem;
}

/* 발견 모달 */
.discovery { text-align: center; padding: 8px 0; }
.disc-title { font-weight: bold; font-size: 1.05rem; color: var(--gold); margin-bottom: 10px; }
.disc-img img.big { width: 72px; height: 72px; animation: discpop .5s cubic-bezier(.2, 2, .4, 1); }
@keyframes discpop { from { transform: scale(.2) rotate(-15deg); } }
.disc-name { font-size: 1.1rem; font-weight: bold; margin: 8px 0 4px; }
.disc-val { color: var(--sub); font-size: .82rem; margin-bottom: 14px; }
.welcomelist { text-align: left; margin: 12px auto; max-width: 260px; line-height: 2; font-size: .88rem; }

/* 토스트 */
#toasts { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 100; width: min(92vw, 400px); pointer-events: none; }
.toast {
  background: rgba(30, 22, 55, .95); border: 1px solid var(--accent);
  border-radius: 12px; padding: 9px 14px; margin-bottom: 6px; font-size: .82rem;
  opacity: 0; transform: translateY(-8px); transition: all .25s; text-align: center;
}
.toast.show { opacity: 1; transform: none; }

/* 스파클 */
.spark {
  position: fixed; z-index: 90; pointer-events: none; font-size: 1rem;
  animation: sparkfly .9s ease-out forwards;
}
@keyframes sparkfly {
  to { transform: translateY(-46px) scale(.4); opacity: 0; }
}

/* 하단 네비 */
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(23, 18, 38, .97); border-top: 1px solid var(--line);
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
}
.navbtn {
  flex: 1; max-width: 170px; background: none; border: none; color: var(--sub);
  font-family: inherit; font-size: .78rem; padding: 7px 4px; border-radius: 10px; cursor: pointer;
}
.navbtn .navicon { display: block; font-size: 1.15rem; margin-bottom: 2px; }
.navbtn.on { color: var(--txt); background: var(--card2); }
