/* ============================================================
   낚시 도감 — 스타일
   모바일 우선, 세로형 앱 레이아웃
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0e1622;
  --panel: #17212e;
  --panel-2: #1e2b3a;
  --line: #2a3a4d;
  --text: #e8eef5;
  --muted: #8fa2b5;
  --gold: #ffcf4a;
  --accent: #2f9bff;
  --good: #4caf50;
  --danger: #ff5470;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  overflow: hidden;
}
#app {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* ---------- 상단 바 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand { font-weight: 800; font-size: 17px; }
.topbar-stats { display: flex; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 700;
}
.chip .ico { font-size: 14px; }
.chip.gold #gold { color: var(--gold); }

/* ---------- 탭 컨테이너 ---------- */
.tab {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.tab.active { display: flex; flex-direction: column; }
.tab h2 { font-size: 15px; margin: 4px 0 10px; color: var(--muted); font-weight: 700; }

/* ---------- 낚시 씬 ---------- */
.scene {
  border-radius: 18px; overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #7ec8a8, #3f8f77);
  transition: background 0.6s ease;
  margin-bottom: 14px;
}
.scene-zone {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px 6px; color: #06232a;
}
.scene-zone > span:first-child { font-weight: 800; font-size: 16px; }
.zone-desc { font-size: 12px; opacity: 0.8; }
.water {
  position: relative; height: 190px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.water::before {
  content: ""; position: absolute; inset: 0;
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,0.06) 0 2px, transparent 2px 22px);
  animation: waves 3s linear infinite;
}
@keyframes waves { from { transform: translateY(0);} to { transform: translateY(22px);} }
.bobber {
  font-size: 44px; position: relative; z-index: 2;
  animation: float 2.2s ease-in-out infinite;
  transition: transform 0.2s;
}
.bobber.biting { animation: shake 0.28s ease-in-out infinite; }
.bobber.reeling { animation: reel 0.5s ease-in-out infinite; }
@keyframes float { 0%,100%{transform:translateY(-4px);} 50%{transform:translateY(6px);} }
@keyframes shake { 0%,100%{transform:translate(-3px,2px) rotate(-6deg);} 50%{transform:translate(3px,-3px) rotate(6deg);} }
@keyframes reel { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-10px);} }
.ripple {
  position: absolute; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5); opacity: 0; z-index: 1;
}
.ripple.go { animation: ripple 0.8s ease-out; }
@keyframes ripple {
  from { opacity: 0.7; transform: scale(0.3); }
  to   { opacity: 0; transform: scale(4); }
}

/* ---------- 좌측 고양이 무대 ---------- */
.cat-stage {
  position: absolute; left: 10px; bottom: 6px; z-index: 3;
  width: 118px; height: 128px;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none;
}
.cat-sprite {
  width: 100%; height: 100%;
  display: flex; align-items: flex-end; justify-content: center;
  background-repeat: no-repeat; background-position: center bottom; background-size: contain;
  transform-origin: bottom center;
}
.cat-sprite img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }
/* 에셋 없을 때 임시 이모지 크기 */
.cat-sprite.is-placeholder { font-size: 44px; line-height: 1; padding-bottom: 6px; }

/* (B) 스프라이트 시트 재생 */
.cat-sprite.sheet {
  background-size: calc(var(--frames, 1) * 100%) 100%;
  background-position: 0 0;
  animation: cat-sheet var(--dur, 1s) steps(var(--frames, 1)) infinite;
}
@keyframes cat-sheet { to { background-position-x: 100%; } }

/* 에셋 넣기 전, 상태별로 임시 이모지에 살짝 움직임을 줘서 구분 */
.cat-stage[data-state="fishing"] .cat-sprite.is-placeholder { animation: cat-bob 1.4s ease-in-out infinite; }
.cat-stage[data-state="bite"]    .cat-sprite.is-placeholder { animation: cat-shake 0.3s ease-in-out infinite; }
.cat-stage[data-state="eating"]  .cat-sprite.is-placeholder { animation: cat-nom 0.35s ease-in-out infinite; }
.cat-stage[data-state="happy"]   .cat-sprite.is-placeholder { animation: cat-bob 0.8s ease-in-out infinite; }
@keyframes cat-bob   { 0%,100%{transform:translateY(0);}       50%{transform:translateY(-6px);} }
@keyframes cat-shake { 0%,100%{transform:translateX(-3px) rotate(-5deg);} 50%{transform:translateX(3px) rotate(5deg);} }
@keyframes cat-nom   { 0%,100%{transform:scale(1);}            50%{transform:scale(1.09);} }
.status-line {
  text-align: center; padding: 10px; font-size: 13px; font-weight: 700;
  color: #06232a; background: rgba(255,255,255,0.22);
}

/* ---------- 낚시 버튼 ---------- */
.cast-btn {
  width: 100%; padding: 18px; border: none; border-radius: 16px;
  font-size: 18px; font-weight: 800; color: #fff; cursor: pointer;
  background: linear-gradient(180deg, #3aa0ff, #1d7ce0);
  box-shadow: 0 6px 0 #155ba8; transition: transform 0.05s, box-shadow 0.05s;
  margin-bottom: 12px;
}
.cast-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #155ba8; }
.cast-btn.waiting { background: linear-gradient(180deg,#5a6b7d,#3f4d5c); box-shadow:0 6px 0 #2a333d; }
.cast-btn.bite {
  background: linear-gradient(180deg,#ffd24a,#ff9d1e); box-shadow:0 6px 0 #c26a00; color:#3a2400;
  animation: pulse 0.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{transform:scale(1);} 50%{transform:scale(1.04);} }

/* ---------- 잡은 물고기 카드 ---------- */
.catch-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px; margin-bottom: 12px;
  animation: pop 0.35s cubic-bezier(.2,1.4,.4,1);
}
.catch-card.hidden { display: none; }
@keyframes pop { from{transform:scale(0.85);opacity:0;} to{transform:scale(1);opacity:1;} }
.catch-emoji { font-size: 52px; line-height: 1; }
.catch-emoji.glow { filter: drop-shadow(0 0 10px currentColor); }
.catch-body { flex: 1; min-width: 0; }
.catch-name { font-weight: 800; font-size: 17px; display:flex; align-items:center; gap:6px; }
.catch-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rarity-tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; color:#0a0f16; }
.badge { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; }
.badge.new { background: var(--good); color: #06210d; }
.badge.record { background: var(--gold); color: #3a2a00; }
.badge.perfect { background: #ff6ba6; color:#2a0013; }
.catch-value { text-align: right; font-weight: 800; color: var(--gold); white-space: nowrap; }

/* ---------- 가방 바 ---------- */
.bag-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 12px;
}
.bag-info { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bag-label { font-weight: 800; }
.bag-value { color: var(--gold); font-weight: 800; }
.sell-btn {
  border: none; background: var(--good); color: #06210d; font-weight: 800;
  padding: 10px 16px; border-radius: 10px; cursor: pointer; font-size: 13px;
}
.sell-btn:disabled { opacity: 0.4; }

/* ---------- 자동 토글 ---------- */
.auto-toggle {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700;
  color: var(--muted); padding: 4px 2px;
}
.auto-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.auto-hint { font-size: 11px; font-weight: 600; }

/* ---------- 도감 ---------- */
.dex-head { display: flex; align-items: baseline; justify-content: space-between; }
.dex-count { color: var(--muted); font-size: 13px; font-weight: 700; }
.dex-filter { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.filter-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.dex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dex-cell {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 8px; text-align: center; cursor: pointer; position: relative;
  transition: transform 0.08s;
}
.dex-cell:active { transform: scale(0.96); }
.dex-cell.locked { opacity: 0.55; }
.dex-cell .demoji { font-size: 34px; line-height: 1.2; }
.dex-cell.locked .demoji { filter: grayscale(1) brightness(0.3); }
.dex-cell .dname { font-size: 12px; font-weight: 700; margin-top: 4px; }
.dex-cell .dname.hidden-name { color: var(--muted); }
.dex-cell .dcount { font-size: 10px; color: var(--muted); margin-top: 2px; }
.dex-cell .rdot { position:absolute; top:8px; right:8px; width:8px; height:8px; border-radius:50%; }

/* ---------- 상점 ---------- */
.shop-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
}
.shop-item.equipped { border-color: var(--accent); }
.shop-emoji { font-size: 30px; }
.shop-body { flex: 1; min-width: 0; }
.shop-name { font-weight: 800; font-size: 14px; }
.shop-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.shop-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.shop-tag { font-size: 10px; background: var(--panel-2); border:1px solid var(--line); color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.shop-btn {
  border: none; border-radius: 10px; padding: 9px 14px; font-weight: 800; font-size: 12px; cursor: pointer;
  background: var(--accent); color: #fff; white-space: nowrap;
}
.shop-btn.owned { background: var(--panel-2); color: var(--muted); }
.shop-btn.equip { background: var(--good); color:#06210d; }
.shop-btn:disabled { opacity: 0.4; }

/* ---------- 통계 ---------- */
.stats-body { display: flex; flex-direction: column; gap: 10px; }
.stat-row {
  display: flex; justify-content: space-between;
  background: var(--panel); border:1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 14px;
}
.stat-row .k { color: var(--muted); }
.stat-row .v { font-weight: 800; }
.reset-btn {
  margin-top: 20px; border: 1px solid var(--danger); color: var(--danger);
  background: transparent; padding: 12px; border-radius: 12px; font-weight: 700; cursor: pointer;
}

/* ---------- 상단 탭바 ---------- */
.tabbar {
  display: flex; gap: 6px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); background: var(--panel); flex-shrink: 0;
}
.tabbtn {
  flex: 1; border: 1px solid transparent; border-radius: 12px;
  background: var(--panel-2); color: var(--muted);
  padding: 8px 0; font-size: 12px; font-weight: 700; cursor: pointer;
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 5px;
  transition: background 0.12s, color 0.12s;
}
.tabbtn span { font-size: 17px; }
.tabbtn.active { color: #fff; background: var(--accent); border-color: var(--accent); }

/* ---------- 토스트 & 모달 ---------- */
.toast {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #000d; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 700; z-index: 50; white-space: nowrap;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.hidden { opacity: 0; transform: translate(-50%, 10px); pointer-events: none; }
.modal {
  position: absolute; inset: 0; background: #000a; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; width: 100%; max-width: 340px; text-align: center;
  animation: pop 0.3s cubic-bezier(.2,1.4,.4,1);
}
.modal-box h3 { font-size: 18px; margin-bottom: 10px; }
.modal-box p { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 16px; }
.modal-box .big { font-size: 40px; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button {
  flex: 1; padding: 12px; border-radius: 12px; border: none; font-weight: 800; cursor: pointer; font-size: 14px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--panel-2); color: var(--muted); }

.hidden { display: none !important; }
