/* ═══════════════════════════════════════════════════════════════
   Pocket Valley DX — ui-rpg.css
   양피지 우드테두리 RPG UI: HUD · 토스트 · 대화 · 모달 · 낚시
   ═══════════════════════════════════════════════════════════════ */

:root {
  --parchment: #fff8e6;
  --parchment-2: #f7ecd0;
  --parchment-3: #efe0ba;
  --wood: #8b5e34;
  --wood-dark: #6b4423;
  --wood-light: #b07f45;
  --ink: #3d2c1a;
  --ink-dim: #7a6547;
  --gold: #c99327;
  --gold-light: #f2c94c;
  --danger: #c0392b;
  --success: #4e7a45;
  --info: #3d6e9e;
  --panel-shadow: 0 10px 28px rgba(30, 18, 4, 0.45), 0 3px 8px rgba(30, 18, 4, 0.3);
  --font-rpg: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR",
    "Segoe UI", system-ui, sans-serif;
}

/* 양피지 패널 공통 (우드 이중 테두리) */
.rpg-panel,
#dialogue .dialogue-inner,
.modal-panel,
#fishing-ui {
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.55) 0%, transparent 55%),
    linear-gradient(180deg, var(--parchment) 0%, var(--parchment-2) 100%);
  border: 3px solid var(--wood);
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 2px var(--parchment-3),
    inset 0 0 0 4px rgba(139, 94, 52, 0.35),
    var(--panel-shadow);
  color: var(--ink);
  font-family: var(--font-rpg);
}

/* ─────────────────────── HUD ─────────────────────── */

.hud {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.hud-right { align-items: flex-end; }

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 62vw;
  padding: 3px 8px;
  border-radius: 999px;
  border: 2px solid var(--wood);
  background: linear-gradient(180deg, rgba(255, 248, 230, 0.88), rgba(247, 236, 208, 0.85));
  box-shadow: 0 2px 6px rgba(30, 18, 4, 0.35), inset 0 1px 0 #fff;
  color: var(--ink);
  font-family: var(--font-rpg);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-location { font-size: 12.5px; }
.hud-date { font-size: 11px; color: var(--ink-dim); }
.hud-gold {
  color: #8a5f10;
  border-color: var(--gold);
  background: linear-gradient(180deg, #fff6d8, #f7e3a1);
}
.hud-equipped { font-size: 11.5px; }
.hud-hp-track {
  display: inline-block;
  width: 44px;
  height: 7px;
  border-radius: 999px;
  background: rgba(58, 42, 18, 0.25);
  overflow: hidden;
  vertical-align: middle;
}
.hud-hp-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: #7ed957;
  transition: width 0.25s ease;
}
.hud-hp.is-low {
  border-color: #e63950;
  color: #b81f38;
  animation: hud-hp-pulse 0.8s ease-in-out infinite alternate;
}
.hud-xp-fill { background: #7ec8e3; }
.hud-level { color: #2e5a8a; }
.hud-weather { padding: 3px 7px; }
.hud-buff { color: #8a5f10; border-color: var(--gold); }
.hud-objective {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  max-width: 92%;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid var(--wood);
  background: linear-gradient(180deg, rgba(255, 248, 230, 0.94), rgba(247, 236, 208, 0.92));
  box-shadow: 0 3px 10px rgba(30, 18, 4, 0.4);
  color: var(--ink);
  font-family: var(--font-rpg);
  font-size: 12.5px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  z-index: 5;
}
.hud-objective.is-hidden { display: none; }

@keyframes hud-hp-pulse {
  from { box-shadow: 0 2px 6px rgba(30, 18, 4, 0.35), inset 0 1px 0 #fff; }
  to { box-shadow: 0 2px 10px rgba(230, 57, 80, 0.55), inset 0 1px 0 #fff; }
}

@media (max-width: 380px) {
  .hud-pill { font-size: 10.5px; padding: 3px 8px; }
  .hud-location { font-size: 11px; }
}

/* ─────────────────────── 토스트 ─────────────────────── */

#toast {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(82%, 360px);
  padding: 6px 12px;
  border-radius: 999px;
  border: 2.5px solid var(--wood);
  background: linear-gradient(180deg, var(--parchment), var(--parchment-2));
  box-shadow: var(--panel-shadow), inset 0 1px 0 #fff;
  color: var(--ink);
  font-family: var(--font-rpg);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  animation: toast-in 0.22s ease-out;
}
#toast.is-hidden { display: none !important; pointer-events: none !important; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -8px) scale(0.96); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ─────────────────────── 대화창 ─────────────────────── */

#dialogue {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 25;
  pointer-events: auto;
}
#dialogue.is-hidden { display: none !important; pointer-events: none !important; }

.dialogue-inner {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px 16px;
  animation: dialogue-in 0.18s ease-out;
}
@keyframes dialogue-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#dialogue-portrait {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 10px;
  border: 2.5px solid var(--wood);
  background: linear-gradient(180deg, #dff0d8, #bfe0b2);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.5), 0 2px 5px rgba(30,18,4,0.25);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.dialogue-main {
  flex: 1 1 auto;
  min-width: 0;
  padding-bottom: 4px;
}

#dialogue-name {
  display: inline-block;
  margin-bottom: 5px;
  padding: 2px 12px;
  border-radius: 999px;
  border: 2px solid var(--wood-dark);
  background: linear-gradient(180deg, var(--wood-light), var(--wood));
  color: #fff8e6;
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.35);
  box-shadow: 0 2px 4px rgba(30,18,4,0.3);
}

#dialogue-text {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--ink);
  word-break: keep-all;
  overflow-wrap: break-word;
  min-height: 2.9em;
}

#dialogue-gift {
  margin-top: 4px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid #c94f6d;
  background: linear-gradient(180deg, #ffb3c6, #ff8fab);
  color: #5c1a2e;
  font-family: var(--font-rpg);
  font-size: 12.5px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(92, 26, 46, 0.3);
}
#dialogue-gift:active { transform: scale(0.96); }
#dialogue-gift.is-hidden { display: none !important; }

#dialogue-arrow {
  position: absolute;
  right: 14px;
  bottom: 8px;
  font-size: 13px;
  color: var(--wood);
  animation: arrow-blink 0.9s ease-in-out infinite;
}
@keyframes arrow-blink {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.25; transform: translateY(3px); }
}

/* ─────────────────────── 낚시 UI ─────────────────────── */

#fishing-ui {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 24;
  padding: 12px 16px 10px;
  text-align: center;
  pointer-events: auto;
  animation: dialogue-in 0.18s ease-out;
}
#fishing-ui.is-hidden { display: none !important; pointer-events: none !important; }

#fishing-msg {
  font-size: 14px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 9px;
  min-height: 1.4em;
}

#fishing-bar {
  position: relative;
  height: 26px;
  border-radius: 999px;
  border: 2.5px solid var(--wood-dark);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), transparent 45%),
    linear-gradient(90deg, #8ec9e8, #5aa7d6 55%, #3d84b8);
  box-shadow: inset 0 2px 5px rgba(20, 50, 80, 0.4), 0 2px 5px rgba(30,18,4,0.25);
  overflow: hidden;
}

#fishing-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(46, 204, 113, 0.55), rgba(39, 174, 96, 0.7));
  pointer-events: none;
}

#fishing-ui.is-bite #fishing-msg {
  color: #c0392b;
  animation: fishing-bite-pulse 0.32s ease-in-out infinite alternate;
}
#fishing-ui.is-bite #fishing-bar {
  border-color: #c0392b;
  box-shadow: 0 0 12px rgba(192, 57, 43, 0.55), inset 0 2px 5px rgba(20, 50, 80, 0.4);
}
@keyframes fishing-bite-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

#fishing-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  /* left/width는 JS가 %로 지정 */
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 214, 64, 0.45);
  box-shadow: 0 0 8px rgba(255, 214, 64, 0.55);
  pointer-events: none;
}

#fishing-fish {
  position: absolute;
  top: 50%;
  /* left는 JS가 %로 지정 */
  transform: translate(-50%, -50%);
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.35));
  pointer-events: none;
  transition: left 0.05s linear;
}

.fishing-hint {
  margin-top: 8px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-dim);
}

/* ─────────────────────── 모달 ─────────────────────── */

#modal-root {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(24, 16, 6, 0.52);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: auto;
}
#modal-root.is-hidden { display: none !important; pointer-events: none !important; }

.modal-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 430px;
  max-height: 100%;
  overflow: hidden;
  animation: modal-in 0.2s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 2px dashed rgba(139, 94, 52, 0.45);
  flex: 0 0 auto;
}
#modal-title {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.3px;
  color: var(--ink);
}
#modal-close {
  appearance: none;
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  border: 2.5px solid var(--wood-dark);
  background: linear-gradient(180deg, #e07a5f, var(--danger));
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--wood-dark), 0 4px 7px rgba(30,18,4,0.3);
  touch-action: manipulation;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
#modal-close:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--wood-dark), 0 2px 4px rgba(30,18,4,0.3);
}
#modal-close:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* 탭 */
#modal-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px 0;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
}
#modal-tabs::-webkit-scrollbar { display: none; }
#modal-tabs:empty { display: none; padding: 0; }

#modal-tabs button,
.tab-btn {
  appearance: none;
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px 999px 10px 10px;
  border: 2px solid var(--wood);
  background: linear-gradient(180deg, var(--parchment-3), #e4cf9c);
  color: var(--ink-dim);
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease, transform 0.06s ease;
}
#modal-tabs button:active,
.tab-btn:active { transform: translateY(1px); }
#modal-tabs button.active,
#modal-tabs button.is-active,
.tab-btn.active,
.tab-btn.is-active {
  background: linear-gradient(180deg, var(--wood-light), var(--wood));
  color: #fff8e6;
  border-color: var(--wood-dark);
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  box-shadow: 0 2px 5px rgba(30,18,4,0.3);
}

/* 모달 본문 */
#modal-body {
  padding: 12px 14px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  flex: 1 1 auto;
  min-height: 0;
}
#modal-body::-webkit-scrollbar { width: 8px; }
#modal-body::-webkit-scrollbar-thumb {
  background: rgba(139, 94, 52, 0.5);
  border-radius: 999px;
  border: 2px solid var(--parchment-2);
}
#modal-body::-webkit-scrollbar-track { background: transparent; }

#modal-body p { margin-bottom: 8px; word-break: keep-all; }
#modal-body h3 {
  font-size: 14px;
  font-weight: 900;
  margin: 12px 0 7px;
  color: var(--wood-dark);
}
#modal-body h3:first-child { margin-top: 0; }
#modal-body .dim, #modal-body .muted { color: var(--ink-dim); }
#modal-body .gold-text { color: #8a5f10; font-weight: 900; }
#modal-body .empty-msg {
  padding: 18px 10px;
  text-align: center;
  color: var(--ink-dim);
  font-weight: 700;
}

/* ── 목록 행 (상점/가방/요리/버스/의뢰/도감 공통) ── */
.modal-list,
#modal-body ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.modal-row,
.shop-item,
.bag-item,
.cook-item,
.bus-item,
.quest-item,
.dex-item,
#modal-body li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 2px solid rgba(139, 94, 52, 0.45);
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.15));
  box-shadow: 0 1px 3px rgba(30,18,4,0.12);
}
.modal-row.is-equipped,
.bag-item.is-equipped {
  border-color: var(--gold);
  background: linear-gradient(180deg, #fff6d8, #f7e3a1);
  box-shadow: 0 0 0 2px rgba(242, 201, 76, 0.35), 0 2px 5px rgba(30,18,4,0.2);
}
.modal-row.is-locked,
.dex-item.is-locked {
  opacity: 0.55;
  filter: grayscale(0.5);
}
.modal-row.is-done,
.quest-item.is-done {
  border-color: var(--success);
  background: linear-gradient(180deg, #eef6e9, #dcefd2);
}

.item-icon {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 9px;
  border: 2px solid rgba(139, 94, 52, 0.4);
  background: rgba(255, 255, 255, 0.6);
  font-size: 20px;
  line-height: 1;
}
.item-main { flex: 1 1 auto; min-width: 0; }
.item-name {
  display: block;
  font-size: 13.5px;
  font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-desc {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-dim);
  line-height: 1.4;
  word-break: keep-all;
}
.item-price {
  flex: 0 0 auto;
  font-size: 12.5px;
  font-weight: 900;
  color: #8a5f10;
  white-space: nowrap;
}
.item-qty {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--parchment-3);
  border: 1.5px solid rgba(139, 94, 52, 0.5);
  font-size: 11px;
  font-weight: 900;
  color: var(--wood-dark);
}

/* ── RPG 버튼 (모달 안의 모든 실제 버튼) ── */
.rpg-btn,
#modal-body button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  padding: 8px 15px;
  border-radius: 11px;
  border: 2.5px solid var(--wood-dark);
  background: linear-gradient(180deg, var(--parchment), var(--parchment-3));
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--wood-dark), 0 4px 7px rgba(30,18,4,0.25);
  touch-action: manipulation;
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.12s ease;
  white-space: nowrap;
}
.rpg-btn:active,
#modal-body button:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--wood-dark), 0 2px 4px rgba(30,18,4,0.25);
}
.rpg-btn:focus-visible,
#modal-body button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.rpg-btn:disabled,
#modal-body button:disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
  cursor: not-allowed;
  transform: none;
}
.rpg-btn.primary,
#modal-body button.primary {
  background: linear-gradient(180deg, #7fae72, var(--success));
  border-color: #33542c;
  color: #f4ffef;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  box-shadow: 0 3px 0 #33542c, 0 4px 7px rgba(30,18,4,0.3);
}
.rpg-btn.primary:active,
#modal-body button.primary:active { box-shadow: 0 0 0 #33542c, 0 2px 4px rgba(30,18,4,0.25); }
.rpg-btn.danger,
#modal-body button.danger {
  background: linear-gradient(180deg, #e07a5f, var(--danger));
  border-color: #7c241a;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  box-shadow: 0 3px 0 #7c241a, 0 4px 7px rgba(30,18,4,0.3);
}
.rpg-btn.danger:active,
#modal-body button.danger:active { box-shadow: 0 0 0 #7c241a, 0 2px 4px rgba(30,18,4,0.25); }
.rpg-btn.gold,
#modal-body button.gold {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  border-color: #8a5f10;
  color: #4a3205;
  box-shadow: 0 3px 0 #8a5f10, 0 4px 7px rgba(30,18,4,0.3);
}
.rpg-btn.small,
#modal-body button.small {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 9px;
}
.rpg-btn.block,
#modal-body button.block { width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.btn-row .rpg-btn, .btn-row button { flex: 1 1 auto; }

/* ── 섹션 구분/정보 박스 ── */
.info-box {
  padding: 10px 12px;
  border-radius: 11px;
  border: 2px dashed rgba(139, 94, 52, 0.55);
  background: rgba(255, 255, 255, 0.4);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.55;
  margin-bottom: 10px;
  word-break: keep-all;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 900;
  color: var(--wood-dark);
  margin: 14px 0 8px;
}
.section-title::after {
  content: "";
  flex: 1 1 auto;
  height: 2px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, rgba(139,94,52,0.5) 0 6px, transparent 6px 11px);
}
.section-title:first-child { margin-top: 0; }

/* ── 호감도 하트/진행 바 ── */
.hearts { color: #e05252; letter-spacing: 1px; font-size: 12px; }
.hearts .heart-off { color: rgba(139, 94, 52, 0.3); }

.progress-track {
  height: 12px;
  border-radius: 999px;
  border: 2px solid var(--wood-dark);
  background: rgba(139, 94, 52, 0.18);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-light), var(--gold));
  transition: width 0.3s ease;
}

/* ── 도감 그리드 ── */
.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 7px;
}
.dex-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 5px;
  border-radius: 11px;
  border: 2px solid rgba(139, 94, 52, 0.45);
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.15));
  text-align: center;
}
.dex-cell .item-icon { width: 34px; height: 34px; flex-basis: 34px; font-size: 18px; }
.dex-cell .item-name { font-size: 11px; white-space: normal; }
.dex-cell.is-locked { opacity: 0.5; filter: grayscale(0.7); }

/* ── 메뉴/도움말 ── */
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.help-table th, .help-table td {
  padding: 6px 8px;
  border-bottom: 1.5px dashed rgba(139, 94, 52, 0.35);
  text-align: left;
  vertical-align: top;
}
.help-table th {
  font-weight: 900;
  color: var(--wood-dark);
  white-space: nowrap;
  width: 38%;
}
kbd.key {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1.5px solid var(--wood);
  border-bottom-width: 3px;
  background: var(--parchment);
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  color: var(--ink);
}

/* 테마 선택 스와치 */
.theme-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-swatch {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 3px solid var(--wood);
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(30,18,4,0.3);
  touch-action: manipulation;
}
.theme-swatch.is-active { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-light), 0 2px 5px rgba(30,18,4,0.3); }
.theme-swatch[data-theme="sage"]  { background: linear-gradient(160deg, #a8c3a0, #8fb088); }
.theme-swatch[data-theme="cream"] { background: linear-gradient(160deg, #f0e3c8, #e0cda3); }
.theme-swatch[data-theme="berry"] { background: linear-gradient(160deg, #e3a7b8, #cf8299); }
.theme-swatch[data-theme="indigo"]{ background: linear-gradient(160deg, #7d8fc9, #5f71ad); }

/* 작은 화면 보정 */
@media (max-width: 380px) {
  #dialogue-text { font-size: 13.5px; }
  #modal-title { font-size: 15.5px; }
  #modal-body { font-size: 12.5px; padding: 10px 11px 14px; }
  .rpg-btn, #modal-body button { font-size: 12px; padding: 7px 11px; }
  #fishing-msg { font-size: 13px; }
}

/* 모션 감소 선호 */
@media (prefers-reduced-motion: reduce) {
  #dialogue-arrow { animation: none; opacity: 1; }
  .dialogue-inner, .modal-panel, #toast, #fishing-ui { animation: none; }
  #fishing-fish { transition: none; }
}

/* ═══════════ v5.1 디자인 업그레이드 ═══════════ */

/* 메뉴 타일 그리드 (도감/업적/호감도 바로가기) */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 4px 0 12px;
}
.menu-tile {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 4px 10px;
  border-radius: 16px;
  border: 2.5px solid var(--wood-dark);
  background: linear-gradient(180deg, #fffdf4 0%, var(--parchment-2) 70%, var(--parchment-3) 100%);
  box-shadow: 0 4px 0 var(--wood-dark), 0 8px 14px rgba(30,18,4,0.22), inset 0 1px 0 #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.15s ease;
}
.menu-tile:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--wood-dark), 0 3px 6px rgba(30,18,4,0.2), inset 0 1px 0 #fff;
  filter: brightness(1.04);
}
.menu-tile-icon { font-size: 26px; line-height: 1.1; filter: drop-shadow(0 2px 2px rgba(30,18,4,0.25)); }
.menu-tile-label { font-size: 14px; font-weight: 900; letter-spacing: 0.5px; }
.menu-tile-sub { font-size: 10px; font-weight: 700; color: var(--ink-dim); text-align: center; line-height: 1.3; }

/* 업적/호감도 카드 */
.ach-card, .aff-card {
  padding: 11px 12px 10px;
  margin-bottom: 8px;
  border-radius: 14px;
  border: 2px solid rgba(139, 94, 52, 0.5);
  background: linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.2));
  box-shadow: 0 2px 5px rgba(30,18,4,0.12), inset 0 1px 0 rgba(255,255,255,0.8);
}
.ach-card.is-done {
  border-color: var(--gold);
  background: linear-gradient(180deg, #fff8dc, #f9e7ae);
  box-shadow: 0 0 0 2px rgba(242,201,76,0.35), 0 3px 8px rgba(30,18,4,0.18);
}
.ach-head { display: flex; align-items: center; gap: 10px; }
.ach-icon {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 12px;
  border: 2px solid rgba(139,94,52,0.45);
  background: radial-gradient(circle at 35% 30%, #fffdf2, var(--parchment-3));
  font-size: 21px;
}
.ach-card.is-done .ach-icon { border-color: var(--gold); background: radial-gradient(circle at 35% 30%, #fffbe8, #f2c94c); }
.ach-texts { flex: 1 1 auto; min-width: 0; }
.ach-name { font-size: 13.5px; font-weight: 900; color: var(--ink); }
.ach-desc { font-size: 11px; font-weight: 600; color: var(--ink-dim); line-height: 1.4; word-break: keep-all; }
.ach-reward {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  border: 1.5px solid #8a5f10;
  color: #4d3405;
  font-size: 11.5px; font-weight: 900;
  box-shadow: 0 2px 4px rgba(30,18,4,0.2);
}
.ach-bar {
  height: 9px;
  margin-top: 9px;
  border-radius: 999px;
  background: rgba(107, 68, 35, 0.22);
  border: 1px solid rgba(107, 68, 35, 0.35);
  overflow: hidden;
}
.ach-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ec8e3, #3d6e9e);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
  transition: width 0.35s ease;
}
.ach-card.is-done .ach-fill { background: linear-gradient(90deg, var(--gold-light), var(--gold)); }
.ach-fill.is-heart { background: linear-gradient(90deg, #ff9db4, #e5537a); }
.ach-progress-text { margin-top: 4px; font-size: 10.5px; font-weight: 800; color: var(--ink-dim); text-align: right; }
.ach-card.is-done .ach-progress-text { color: #8a5f10; }

/* 섹션 제목 액센트 */
#modal-body h3, .m-section-title {
  display: flex; align-items: center; gap: 7px;
}
#modal-body h3::before, .m-section-title::before {
  content: "";
  width: 5px; height: 15px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  box-shadow: 0 1px 2px rgba(30,18,4,0.3);
}

/* 목록 행 입체감 */
.modal-row, #modal-body li {
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}
.modal-row:active { transform: scale(0.99); }

/* 모달 헤더 그라데이션 띠 */
.modal-header {
  background: linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0));
  border-bottom: 2px solid rgba(139, 94, 52, 0.5);
}
#modal-title { text-shadow: 0 1px 0 rgba(255,255,255,0.7); }

/* 탭 세그먼트 느낌 강화 */
#modal-tabs button, .tab-btn { border-radius: 999px; padding: 8px 16px; }
#modal-tabs button.is-active, .tab-btn.is-active {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: #4d3405;
  border-color: #8a5f10;
  text-shadow: none;
}

/* HUD 알약 유리감 */
.hud-pill {
  background: linear-gradient(180deg, rgba(255,253,244,0.94), rgba(247,236,208,0.9));
  box-shadow: 0 3px 8px rgba(30,18,4,0.22), inset 0 1px 0 #fff;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.hud-xp-fill { background: linear-gradient(90deg, #9be7ff, #3d9be9); }
.hud-objective {
  background: linear-gradient(180deg, rgba(61,44,26,0.92), rgba(61,44,26,0.85));
  color: #ffe9b8;
  border: 1.5px solid rgba(242,201,76,0.6);
  box-shadow: 0 4px 12px rgba(30,18,4,0.35);
}

/* 토스트 */
.toast, #toast {
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(30,18,4,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
}

/* 대화 이름표 */
#dialogue-name {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--wood-light), var(--wood));
  color: #fff8e6 !important;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  box-shadow: 0 2px 5px rgba(30,18,4,0.3);
}

/* ═══════════ v5.2 디자인 심화 ═══════════ */

/* 모달 콘텐츠 순차 등장 */
@keyframes row-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
#modal-body > * { animation: row-in 0.22s ease-out both; }
#modal-body > *:nth-child(2) { animation-delay: 0.03s; }
#modal-body > *:nth-child(3) { animation-delay: 0.06s; }
#modal-body > *:nth-child(4) { animation-delay: 0.09s; }
#modal-body > *:nth-child(5) { animation-delay: 0.12s; }
#modal-body > *:nth-child(6) { animation-delay: 0.15s; }
#modal-body > *:nth-child(7) { animation-delay: 0.18s; }
#modal-body > *:nth-child(8) { animation-delay: 0.21s; }
#modal-body > *:nth-child(n+9) { animation-delay: 0.24s; }

/* 목록 행 왼쪽 액센트 + 깊이 */
.modal-row, #modal-body li {
  position: relative;
  overflow: hidden;
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(255,255,255,0.28));
  box-shadow: 0 2px 6px rgba(30,18,4,0.13), inset 0 1px 0 rgba(255,255,255,0.85);
}
.modal-row::before, #modal-body li::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  opacity: 0.85;
}

/* 버튼 광택 스윕 */
#modal-body button { position: relative; overflow: hidden; }
#modal-body button::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.45s ease;
  pointer-events: none;
}
#modal-body button:active::after { transform: translateX(120%); }
#modal-body button.is-active {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: #4d3405;
}

/* 달성 카드 반짝임 */
.ach-card.is-done { position: relative; overflow: hidden; }
.ach-card.is-done::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,0.45) 50%, transparent 65%);
  animation: ach-shine 2.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ach-shine {
  0%, 55% { transform: translateX(-130%); }
  85%, 100% { transform: translateX(130%); }
}

/* 낚시 UI */
#fishing-ui {
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(160,220,255,0.35) 0%, transparent 55%),
    linear-gradient(180deg, #fdf6df 0%, #f3e5bb 100%);
}
#fishing-bar {
  border-radius: 999px;
  box-shadow: inset 0 2px 6px rgba(30,18,4,0.35), 0 2px 5px rgba(30,18,4,0.2);
}
#fishing-progress { background: linear-gradient(90deg, #7ec8e3, #3d9be9); }
#fishing-zone { box-shadow: 0 0 10px rgba(242,201,76,0.7); }

/* 대화창 */
#dialogue-portrait {
  border-radius: 14px;
  border: 2.5px solid var(--wood-dark);
  box-shadow: 0 3px 8px rgba(30,18,4,0.3), inset 0 0 0 2px rgba(255,255,255,0.4);
  background: radial-gradient(circle at 40% 30%, #fffdf2, var(--parchment-3));
}
#dialogue-text { animation: row-in 0.18s ease-out; }
#dialogue-arrow { animation: arrow-bob 0.9s ease-in-out infinite; }
@keyframes arrow-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}
#dialogue-gift {
  border-radius: 999px;
  background: linear-gradient(180deg, #ffb3c8, #e5537a);
  border: 2px solid #a12c4c;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 3px 0 #a12c4c, 0 5px 9px rgba(30,18,4,0.25);
}

/* 토스트 등장 */
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.toast, #toast { animation: toast-in 0.22s ease-out; }

/* 스크롤바 슬림 */
#modal-body::-webkit-scrollbar { width: 6px; }
