/* === 江湖行 — 水墨武侠风 === */
@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=Noto+Serif+SC:wght@400;700&display=swap');

:root {
  --bg: #f5f0e8;
  --bg2: #ede6d6;
  --ink: #2c2416;
  --ink2: #5a4a32;
  --accent: #8b1a1a;
  --accent2: #c0392b;
  --blue: #1a3a5c;
  --gold: #b8860b;
  --green: #2d5a27;
  --hp: #c0392b;
  --mp: #2471a3;
  --radius: 6px;
  --font: 'Noto Serif SC', 'Songti SC', serif;
  --font-brush: 'Ma Shan Zheng', cursive;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Screens */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* === Title Screen === */
#screen-title {
  align-items: center; justify-content: center; text-align: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 80%, rgba(139,26,26,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(26,58,92,0.05) 0%, transparent 50%);
}
.title-art { position: relative; margin-bottom: 2rem; }
.ink-circle {
  width: 200px; height: 200px; border-radius: 50%;
  border: 3px solid var(--ink);
  margin: 0 auto 1rem;
  opacity: 0.15;
  animation: inkPulse 4s ease-in-out infinite;
}
@keyframes inkPulse {
  0%,100% { transform: scale(1); opacity: 0.15; }
  50% { transform: scale(1.05); opacity: 0.25; }
}
.title-text {
  font-family: var(--font-brush);
  font-size: 4rem;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -80%);
  color: var(--ink);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}
.subtitle {
  font-size: 1.1rem; color: var(--ink2); letter-spacing: 0.5em;
}
.title-menu { display: flex; flex-direction: column; gap: 0.8rem; }
.title-menu button {
  font-family: var(--font); font-size: 1.1rem;
  padding: 0.8rem 2.5rem;
  background: transparent;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.3s;
  border-radius: var(--radius);
}
.title-menu button:hover {
  background: var(--ink); color: var(--bg);
}
.title-menu button:disabled { opacity: 0.3; cursor: default; }
.footer-note { margin-top: 2rem; font-size: 0.85rem; color: var(--ink2); opacity: 0.6; }

/* === Game Screen === */
#screen-game { padding-bottom: 60px; }

#status-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 0.5rem 1rem;
  padding: 0.5rem 1rem;
  background: var(--bg2);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  font-size: 0.85rem;
}
#sb-hp { color: var(--hp); }
#sb-mp { color: var(--mp); }
#sb-location { color: var(--blue); }
#sb-silver { color: var(--gold); }

#main-text {
  flex: 1;
  padding: 1rem 1.2rem;
  line-height: 1.9;
  overflow-y: auto;
  max-height: calc(100dvh - 160px);
}
#main-text .scene-title {
  font-family: var(--font-brush);
  font-size: 1.6rem;
  margin: 0.5rem 0;
  color: var(--accent);
}
#main-text .narrator {
  color: var(--ink2);
  margin: 0.4rem 0;
}
#main-text .dialogue {
  color: var(--blue);
  margin: 0.3rem 0;
  padding-left: 1em;
  border-left: 2px solid var(--blue);
}
#main-text .system-msg {
  color: var(--green);
  font-size: 0.9rem;
  margin: 0.3rem 0;
  text-align: center;
}
#main-text .divider {
  text-align: center;
  color: var(--ink2);
  opacity: 0.4;
  margin: 0.8rem 0;
  letter-spacing: 0.5em;
}

/* Typewriter cursor */
.typing-cursor::after {
  content: '▎'; animation: blink 0.8s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

#choices {
  padding: 0.5rem 1rem 0.8rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}
#choices button {
  font-family: var(--font); font-size: 0.95rem;
  padding: 0.7rem 1rem;
  background: var(--bg2);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  color: var(--ink);
}
#choices button:hover {
  background: var(--ink); color: var(--bg);
}
#choices button:active { transform: scale(0.98); }

#nav-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--bg2);
  border-top: 1px solid rgba(0,0,0,0.1);
  z-index: 20;
}
#nav-bar button {
  flex: 1;
  padding: 0.5rem 0.2rem;
  font-size: 0.75rem;
  font-family: var(--font);
  background: transparent;
  border: none;
  color: var(--ink2);
  cursor: pointer;
}
#nav-bar button:hover { background: rgba(0,0,0,0.05); }

/* === Combat Screen === */
#screen-combat {
  padding: 0.5rem;
  background: var(--bg);
  background-image: radial-gradient(ellipse at center, rgba(139,26,26,0.03) 0%, transparent 70%);
}
#combat-header {
  display: flex; align-items: center; justify-content: space-around;
  padding: 0.5rem; margin-bottom: 0.5rem;
}
#combat-player-info, #combat-enemy-info {
  text-align: center; min-width: 120px;
}
.combat-name { font-family: var(--font-brush); font-size: 1.3rem; }
.combat-hp-bar, .combat-mp-bar {
  height: 8px; border-radius: 4px; background: rgba(0,0,0,0.1);
  margin: 4px 0; overflow: hidden;
}
.combat-hp-bar .fill { height: 100%; background: var(--hp); transition: width 0.5s; border-radius: 4px; }
.combat-mp-bar .fill { height: 100%; background: var(--mp); transition: width 0.5s; border-radius: 4px; }
.combat-hp-text, .combat-mp-text { font-size: 0.75rem; }
.vs-text { font-size: 2rem; opacity: 0.3; }

#combat-log {
  flex: 1;
  padding: 0.5rem;
  overflow-y: auto;
  max-height: calc(100dvh - 280px);
  line-height: 1.8;
  font-size: 0.9rem;
}
#combat-log .atk-line { color: var(--accent); }
#combat-log .def-line { color: var(--blue); }
#combat-log .heal-line { color: var(--green); }
#combat-log .sys-line { color: var(--ink2); font-style: italic; }

#combat-actions {
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
#combat-actions button {
  font-family: var(--font); font-size: 0.85rem;
  padding: 0.6rem 0.3rem;
  background: var(--bg2);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: var(--radius);
  cursor: pointer; color: var(--ink);
  transition: all 0.2s;
}
#combat-actions button:hover { background: var(--ink); color: var(--bg); }
#combat-actions button.skill-btn { border-color: var(--accent); }

/* === Panel Overlay === */
#panel-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
}
#panel-overlay.hidden { display: none; }
#panel-content {
  background: var(--bg);
  width: 100%; max-width: 500px;
  max-height: 80dvh;
  overflow-y: auto;
  border-radius: 12px 12px 0 0;
  padding: 1rem 1.2rem 2rem;
  position: relative;
}
.panel-close {
  position: absolute; top: 0.5rem; right: 0.8rem;
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--ink2);
}
#panel-body h2 {
  font-family: var(--font-brush);
  font-size: 1.4rem;
  margin-bottom: 0.8rem;
  color: var(--accent);
}
#panel-body .stat-row {
  display: flex; justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px dashed rgba(0,0,0,0.08);
}
#panel-body .item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
#panel-body .item-row button {
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--ink2);
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
#panel-body .item-row button:hover { background: var(--ink); color: var(--bg); }
#panel-body .skill-card {
  padding: 0.6rem; margin-bottom: 0.5rem;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: var(--radius);
}
#panel-body .skill-card .sk-name { font-weight: bold; }
#panel-body .skill-card .sk-type { font-size: 0.8rem; color: var(--ink2); }
#panel-body .skill-card .sk-desc { font-size: 0.85rem; margin-top: 0.2rem; }
#panel-body .quest-card {
  padding: 0.6rem; margin-bottom: 0.5rem;
  border-left: 3px solid var(--gold);
  background: rgba(0,0,0,0.02);
  border-radius: 0 var(--radius) var(--radius) 0;
}
#panel-body .quest-card.completed { border-left-color: var(--green); opacity: 0.7; }
#panel-body .map-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
}
#panel-body .map-loc {
  padding: 0.6rem; text-align: center;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: var(--radius);
  cursor: pointer; font-size: 0.85rem;
  transition: all 0.2s;
}
#panel-body .map-loc:hover { background: var(--ink); color: var(--bg); }
#panel-body .map-loc.current { border-color: var(--accent); background: rgba(139,26,26,0.08); }
#panel-body .map-loc.locked { opacity: 0.4; cursor: default; }
#panel-body .npc-row {
  padding: 0.5rem 0; border-bottom: 1px solid rgba(0,0,0,0.06);
  cursor: pointer;
}
#panel-body .npc-row:hover { background: rgba(0,0,0,0.03); }
#panel-body .rep-bar {
  height: 6px; border-radius: 3px; background: rgba(0,0,0,0.1);
  margin: 2px 0; overflow: hidden;
}
#panel-body .rep-bar .fill { height: 100%; border-radius: 3px; transition: width 0.3s; }

/* === Responsive === */
@media (min-width: 600px) {
  #screen-game, #screen-combat { max-width: 600px; margin: 0 auto; }
  #nav-bar { max-width: 600px; left: 50%; transform: translateX(-50%); }
  #panel-content { border-radius: 12px; margin-bottom: 1rem; }
  #choices { flex-direction: row; flex-wrap: wrap; }
  #choices button { flex: 1; min-width: 45%; }
}

/* === Ink decorations === */
.ink-splash {
  position: fixed; pointer-events: none; opacity: 0.03;
  font-size: 15rem; z-index: -1;
}
.ink-splash.tl { top: -2rem; left: -2rem; }
.ink-splash.br { bottom: -2rem; right: -2rem; transform: rotate(180deg); }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

/* Shop styles */
#panel-body .shop-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0; border-bottom: 1px solid rgba(0,0,0,0.06);
}
#panel-body .shop-item button {
  font-family: var(--font); font-size: 0.8rem;
  padding: 0.3rem 0.8rem; border: 1px solid var(--gold);
  background: transparent; border-radius: var(--radius); cursor: pointer; color: var(--gold);
}
#panel-body .shop-item button:hover { background: var(--gold); color: #fff; }
