/* ==========================================================
   MOONPOND · 달빛 연못 — UI 스타일
   ========================================================== */
:root {
  --font: 'DungGeunMo', 'Galmuri11', monospace;
  --ink: #eef2ff;
  --ink-dim: #9aa5c4;
  --panel: #171a2e;
  --panel-2: #202542;
  --line: #3a4270;
  --accent: #ffd166;
  --r-common: #b8c2d9;
  --r-uncommon: #6ee787;
  --r-rare: #58a6ff;
  --r-epic: #bc8cff;
  --r-legendary: #ffb347;
  --r-mythic: #ff6ec7;
}

* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }

html, body {
  width: 100%; height: 100%;
  background: #05060f;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
}

#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

#frame {
  position: relative;
  line-height: 0; /* 캔버스 아래 여백 제거 */
}
#frame > *:not(canvas) { line-height: normal; }

#game-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #05060f;
}

.hidden { display: none !important; }

#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,10,0.45) 100%);
}

/* ==================== HUD ==================== */
#hud {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
}
#hud-top {
  display: flex; gap: 8px; align-items: center;
  padding: 14px 18px;
}
#hud-spacer { flex: 1; }
.hud-pill, .hud-btn {
  pointer-events: auto;
  background: rgba(13, 16, 34, 0.82);
  border: 2px solid var(--line);
  border-radius: 4px;
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  line-height: 1;
  box-shadow: 0 3px 0 rgba(0,0,0,0.35);
}
.hud-btn {
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease;
}
.hud-btn:hover { background: #2a3054; border-color: #5563a5; transform: translateY(-1px); }
.hud-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.35); }
#zone-box { cursor: pointer; transition: transform 0.08s ease, border-color 0.12s ease; }
#zone-box:hover { border-color: #5563a5; transform: translateY(-1px); }

.coin-icon { color: var(--accent); margin-right: 6px; }
#coin-count { font-variant-numeric: tabular-nums; }

.coin-pop { animation: coinPop 0.35s ease; }
@keyframes coinPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.22); color: var(--accent); }
  100% { transform: scale(1); }
}

#hint-bar {
  align-self: center;
  margin-bottom: 16px;
  pointer-events: none;
  min-height: 30px;
}
#hint-text {
  display: inline-block;
  background: rgba(13, 16, 34, 0.78);
  border: 2px solid var(--line);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--ink-dim);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#hint-text.show { opacity: 1; transform: translateY(0); }

/* ==================== 타이틀 ==================== */
#title-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  text-align: center;
  transition: opacity 0.5s ease;
}
#title-screen.fade-out { opacity: 0; pointer-events: none; }

#title-logo { animation: titleFloat 3.2s ease-in-out infinite; }
@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
#title-moon {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffbe8, #ffe9a3 55%, #e8c25c);
  box-shadow: 0 0 34px 10px rgba(255, 233, 163, 0.35), 0 0 90px 30px rgba(255, 233, 163, 0.12);
}
#title-logo h1 {
  font-size: 54px; letter-spacing: 6px;
  color: #fffbe8;
  text-shadow: 0 4px 0 #2c3163, 0 0 28px rgba(255, 224, 130, 0.45);
}
#title-logo h2 {
  margin-top: 8px;
  font-size: 20px; letter-spacing: 10px;
  color: var(--accent);
  font-weight: normal;
}
#title-press {
  font-size: 16px; color: var(--ink);
  animation: pressBlink 1.4s ease-in-out infinite;
}
@keyframes pressBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
#title-foot { font-size: 12px; color: var(--ink-dim); letter-spacing: 3px; }

/* ==================== 모달 공통 ==================== */
.modal {
  position: absolute; inset: 0;
  background: rgba(4, 5, 14, 0.72);
  display: flex; align-items: center; justify-content: center;
  animation: modalFade 0.18s ease;
  z-index: 30;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  width: min(420px, 92vw);
  max-height: 84vh;
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 0 rgba(0,0,0,0.4), 0 24px 60px rgba(0,0,0,0.6);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: panelIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-panel.wide { width: min(760px, 94vw); }
@keyframes panelIn {
  from { transform: translateY(26px) scale(0.94); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--panel-2);
  border-bottom: 2px solid var(--line);
  font-size: 17px;
}
.modal-close {
  background: none; border: none; color: var(--ink-dim);
  font-family: var(--font); font-size: 16px; cursor: pointer;
  padding: 2px 8px;
  transition: color 0.12s ease, transform 0.12s ease;
}
.modal-close:hover { color: #ff7a7a; transform: scale(1.2); }

/* ==================== 지역 선택 ==================== */
#zone-list { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.zone-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.12s ease;
}
.zone-item:hover:not(.locked) { transform: translateX(4px); border-color: var(--accent); }
.zone-item.current { border-color: var(--r-uncommon); }
.zone-item.locked { opacity: 0.55; cursor: pointer; }
.zone-swatch { width: 34px; height: 34px; border-radius: 4px; border: 2px solid rgba(255,255,255,0.18); flex: none; }
.zone-info { flex: 1; }
.zone-title { font-size: 15px; }
.zone-sub { font-size: 12px; color: var(--ink-dim); margin-top: 3px; }
.zone-price { font-size: 13px; color: var(--accent); }
.zone-check { color: var(--r-uncommon); font-size: 14px; }

/* ==================== 도감 ==================== */
#dex-body { display: flex; min-height: 0; }
#dex-grid {
  flex: 1.4;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  padding: 14px;
  overflow-y: auto;
  align-content: start;
}
.dex-cell {
  aspect-ratio: 1;
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.dex-cell:hover { transform: translateY(-3px); }
.dex-cell.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dex-cell canvas { image-rendering: pixelated; width: 78%; height: 78%; object-fit: contain; }
.dex-cell.unseen canvas { filter: brightness(0) opacity(0.55); }
.dex-cell .dex-count {
  position: absolute; right: 3px; bottom: 2px;
  font-size: 10px; color: var(--ink-dim);
}
.dex-cell[data-rarity]::before {
  content: ''; position: absolute; left: 4px; top: 4px;
  width: 6px; height: 6px; border-radius: 2px;
  background: var(--rc, transparent);
}
.dex-section {
  grid-column: 1 / -1;
  font-size: 13px; color: var(--ink-dim);
  padding: 6px 2px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

#dex-detail {
  flex: 1;
  border-left: 2px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  min-width: 220px;
}
.dex-detail-empty { color: var(--ink-dim); font-size: 13px; text-align: center; margin-top: 40px; }
#dex-detail canvas { image-rendering: pixelated; display: block; margin: 6px auto 12px; width: 96px; height: 96px; }
#dex-detail canvas.unseen { filter: brightness(0) opacity(0.55); }
.dd-name { text-align: center; font-size: 17px; margin-bottom: 4px; }
.dd-rarity { text-align: center; font-size: 12px; margin-bottom: 12px; }
.dd-desc { font-size: 13px; color: var(--ink-dim); line-height: 1.6; margin-bottom: 14px; }
.dd-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-top: 1px solid var(--line); }
.dd-row b { color: var(--accent); font-weight: normal; }

/* ==================== 상점 ==================== */
.shop-coin { font-size: 14px; color: var(--accent); margin-left: 10px; }
#shop-tabs { display: flex; border-bottom: 2px solid var(--line); }
.shop-tab {
  flex: 1; padding: 10px;
  background: var(--panel); border: none;
  color: var(--ink-dim); font-family: var(--font); font-size: 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.shop-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
#shop-list { padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.shop-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 6px;
  transition: border-color 0.12s ease;
}
.shop-item.owned-equipped { border-color: var(--r-uncommon); }
.shop-icon { font-size: 22px; width: 32px; text-align: center; flex: none; }
.shop-info { flex: 1; }
.shop-name { font-size: 15px; }
.shop-desc { font-size: 12px; color: var(--ink-dim); margin-top: 3px; line-height: 1.5; }
.shop-action {
  font-family: var(--font); font-size: 13px;
  padding: 8px 14px;
  border-radius: 4px; border: 2px solid var(--line);
  background: var(--panel); color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease, background 0.12s ease;
  white-space: nowrap;
}
.shop-action.buy { border-color: var(--accent); color: var(--accent); }
.shop-action.buy:hover { background: var(--accent); color: #1a1400; transform: translateY(-1px); }
.shop-action.cant { opacity: 0.45; cursor: not-allowed; }
.shop-action.equip:hover { border-color: var(--r-uncommon); color: var(--r-uncommon); }
.shop-action.equipped { border-color: var(--r-uncommon); color: var(--r-uncommon); cursor: default; }
.shop-item.bought { animation: boughtFlash 0.5s ease; }
@keyframes boughtFlash {
  0% { background: var(--panel-2); }
  30% { background: #4a4420; border-color: var(--accent); }
  100% { background: var(--panel-2); }
}

/* ==================== 캐치 리빌 ==================== */
#reveal-overlay {
  position: absolute; inset: 0;
  background: rgba(4, 5, 14, 0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
  animation: modalFade 0.2s ease;
  cursor: pointer;
}
#reveal-rays {
  position: absolute; width: 560px; height: 560px;
  background: conic-gradient(
    var(--ray, rgba(255,255,255,0.06)) 0deg 12deg, transparent 12deg 30deg,
    var(--ray, rgba(255,255,255,0.06)) 30deg 42deg, transparent 42deg 60deg,
    var(--ray, rgba(255,255,255,0.06)) 60deg 72deg, transparent 72deg 90deg,
    var(--ray, rgba(255,255,255,0.06)) 90deg 102deg, transparent 102deg 120deg,
    var(--ray, rgba(255,255,255,0.06)) 120deg 132deg, transparent 132deg 150deg,
    var(--ray, rgba(255,255,255,0.06)) 150deg 162deg, transparent 162deg 180deg,
    var(--ray, rgba(255,255,255,0.06)) 180deg 192deg, transparent 192deg 210deg,
    var(--ray, rgba(255,255,255,0.06)) 210deg 222deg, transparent 222deg 240deg,
    var(--ray, rgba(255,255,255,0.06)) 240deg 252deg, transparent 252deg 270deg,
    var(--ray, rgba(255,255,255,0.06)) 270deg 282deg, transparent 282deg 300deg,
    var(--ray, rgba(255,255,255,0.06)) 300deg 312deg, transparent 312deg 330deg,
    var(--ray, rgba(255,255,255,0.06)) 330deg 342deg, transparent 342deg 360deg
  );
  border-radius: 50%;
  animation: raysSpin 14s linear infinite;
  mask-image: radial-gradient(circle, black 20%, transparent 68%);
  -webkit-mask-image: radial-gradient(circle, black 20%, transparent 68%);
}
@keyframes raysSpin { to { transform: rotate(360deg); } }

#reveal-card {
  position: relative;
  width: 260px;
  background: var(--panel);
  border: 3px solid var(--rar-color, var(--line));
  border-radius: 10px;
  padding: 22px 18px 16px;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 0 32px var(--rar-glow, transparent), 0 18px 50px rgba(0,0,0,0.6);
  animation: cardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cardIn {
  0% { transform: scale(0.3) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
#reveal-card.mythic-card {
  animation: cardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), mythicBorder 2.4s linear infinite;
}
@keyframes mythicBorder {
  0% { border-color: #ff6ec7; box-shadow: 0 0 32px rgba(255,110,199,0.5), 0 18px 50px rgba(0,0,0,0.6); }
  33% { border-color: #58a6ff; box-shadow: 0 0 32px rgba(88,166,255,0.5), 0 18px 50px rgba(0,0,0,0.6); }
  66% { border-color: #6ee787; box-shadow: 0 0 32px rgba(110,231,135,0.5), 0 18px 50px rgba(0,0,0,0.6); }
  100% { border-color: #ff6ec7; box-shadow: 0 0 32px rgba(255,110,199,0.5), 0 18px 50px rgba(0,0,0,0.6); }
}

#reveal-badges {
  position: absolute; top: -14px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 8px;
}
.badge {
  font-size: 12px; padding: 4px 10px;
  border-radius: 4px;
  animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s backwards;
}
.badge.new { background: var(--accent); color: #1a1400; }
.badge.record { background: var(--r-rare); color: #06131f; }
@keyframes badgePop {
  from { transform: scale(0) rotate(-12deg); }
  to { transform: scale(1) rotate(0); }
}

#reveal-rarity { font-size: 13px; letter-spacing: 3px; color: var(--rar-color, var(--ink-dim)); margin-bottom: 8px; }
#reveal-sprite { image-rendering: pixelated; width: 128px; height: 128px; animation: spriteBob 2s ease-in-out infinite; }
@keyframes spriteBob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}
#reveal-name { font-size: 20px; margin-top: 6px; }
#reveal-size { font-size: 13px; color: var(--ink-dim); margin-top: 6px; }
#reveal-desc { font-size: 12px; color: var(--ink-dim); line-height: 1.6; margin-top: 10px; min-height: 38px; }
#reveal-price { font-size: 16px; color: var(--accent); margin-top: 10px; }
#reveal-continue {
  margin-top: 14px; font-size: 11px; color: var(--ink-dim);
  animation: pressBlink 1.4s ease-in-out infinite;
}

/* ==================== 토스트 ==================== */
#toast-area {
  position: absolute; top: 64px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; z-index: 50;
}
.toast {
  background: rgba(13, 16, 34, 0.92);
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), toastOut 0.3s ease 2.4s forwards;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
}
.toast.gold { border-color: var(--accent); color: var(--accent); }
.toast.bad { border-color: #ff7a7a; color: #ff7a7a; }
@keyframes toastIn {
  from { transform: translateY(-16px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }

/* ==================== 엔딩 ==================== */
#ending-overlay {
  position: absolute; inset: 0;
  background: rgba(4, 5, 14, 0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
  animation: modalFade 0.4s ease;
}
#ending-card {
  text-align: center;
  background: var(--panel);
  border: 3px solid var(--accent);
  border-radius: 12px;
  padding: 40px 48px;
  box-shadow: 0 0 60px rgba(255, 209, 102, 0.35);
  animation: cardIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#ending-crown { font-size: 52px; animation: titleFloat 2.4s ease-in-out infinite; }
#ending-card h1 { font-size: 26px; margin: 14px 0 10px; color: var(--accent); }
#ending-card p { font-size: 15px; margin: 6px 0; }
#ending-card b { color: var(--r-mythic); font-weight: normal; }
.ending-sub { color: var(--ink-dim); font-size: 13px !important; }
#ending-close {
  margin-top: 22px;
  font-family: var(--font); font-size: 14px;
  padding: 10px 22px;
  background: var(--accent); color: #1a1400;
  border: none; border-radius: 6px; cursor: pointer;
  transition: transform 0.1s ease;
}
#ending-close:hover { transform: scale(1.06); }

/* ==================== 콤보 배지 ==================== */
#combo-badge {
  align-self: center;
  background: rgba(30, 16, 8, 0.85);
  border: 2px solid #ff9f43;
  border-radius: 6px;
  color: #ffb86b;
  font-size: 15px;
  padding: 6px 14px;
  box-shadow: 0 0 14px rgba(255, 140, 60, 0.35), 0 3px 0 rgba(0,0,0,0.35);
}
#combo-badge.combo-pop { animation: comboPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes comboPop {
  0% { transform: scale(0.7); }
  50% { transform: scale(1.25) rotate(-2deg); }
  100% { transform: scale(1); }
}

/* ==================== 모험 일지 ==================== */
#journal-tabs { display: flex; border-bottom: 2px solid var(--line); }
.journal-tab {
  flex: 1; padding: 10px;
  background: var(--panel); border: none;
  color: var(--ink-dim); font-family: var(--font); font-size: 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.journal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
#journal-list { padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }

.quest-item {
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
}
.quest-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.quest-desc { font-size: 14px; }
.quest-reward { font-size: 13px; color: var(--accent); }
.quest-bar {
  height: 8px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 4px;
  overflow: hidden;
}
.quest-fill {
  height: 100%; background: var(--r-uncommon);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.quest-progress { font-size: 11px; color: var(--ink-dim); margin-top: 5px; text-align: right; }
.journal-tip { font-size: 11px; color: var(--ink-dim); text-align: center; padding: 6px 0; }

.ach-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 9px 14px;
  opacity: 0.6;
}
.ach-item.done { opacity: 1; border-color: rgba(255, 209, 102, 0.5); }
.ach-mark { width: 24px; text-align: center; font-size: 15px; }
.ach-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ach-name { font-size: 13px; }
.ach-item.done .ach-name { color: var(--accent); }
.ach-desc { font-size: 11px; color: var(--ink-dim); }
.ach-reward { font-size: 11px; color: var(--ink-dim); }
.ach-item.done .ach-reward { color: var(--r-uncommon); }

/* ==================== 황금 개체 ==================== */
.badge.gold { background: linear-gradient(135deg, #ffd166, #ff9f43); color: #3a2400; }
#reveal-card.gold-card {
  animation: cardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), goldPulse 1.6s ease-in-out infinite;
}
@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 24px rgba(255, 209, 102, 0.4), 0 18px 50px rgba(0,0,0,0.6); }
  50% { box-shadow: 0 0 46px rgba(255, 209, 102, 0.75), 0 18px 50px rgba(0,0,0,0.6); }
}
#reveal-combo { font-size: 12px; color: #ffb86b; margin-top: 6px; }
.dex-gold {
  position: absolute; left: 3px; bottom: 2px;
  font-size: 10px; color: var(--accent);
  text-shadow: 0 0 4px rgba(255, 209, 102, 0.8);
}

/* 스크린 플래시 */
.flash { animation: screenFlash 0.25s ease; }
@keyframes screenFlash {
  0% { filter: brightness(1); }
  20% { filter: brightness(2.2); }
  100% { filter: brightness(1); }
}

/* 스크롤바 */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--panel); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #5563a5; }
