/* 《秘境 CACHE》—— 海子 H5 原型样式 */

:root {
  --ink:        #0d1b2a;   /* 墨 */
  --ink-soft:   #1b2b3d;
  --paper:      #f2ece1;   /* 宣纸 */
  --water:      #3fa9c9;   /* 水 */
  --water-deep: #1d6f8b;
  --gold:       #d9a441;   /* 桥桩金 */
  --dust:       #8a8578;   /* 已失 */
  --text:       #f2ece1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* isolation: isolate 让地图成为独立的层叠上下文——
   腾讯地图 SDK 内部注入的元素（鉴权失败水印、比例尺/Logo 面板等）
   有时会设置很高的 z-index，若不隔离，会"穿透"盖住下方 UI 控件，
   导致按钮看起来点不动，实际是点击被地图内部元素截获。 */
#map {
  position: absolute; inset: 0;
  z-index: 1;
  isolation: isolate;
  transition: filter 900ms ease;
}

/* 沉入乾隆层：底图做旧 */
#map.ancient {
  filter: sepia(0.55) saturate(0.65) contrast(1.06) brightness(0.92);
}

/* ---------- 水涨转场 ---------- */
.flood {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 30;
}
.flood.active { opacity: 1; }

.flood-wave {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 0%;
  background: linear-gradient(180deg,
    rgba(63,169,201,0.85) 0%,
    rgba(29,111,139,0.95) 40%,
    rgba(13,27,42,0.98) 100%);
  transition: height 1100ms cubic-bezier(.4,.05,.25,1);
}
.flood-wave-2 {
  background: linear-gradient(180deg,
    rgba(217,164,65,0.5) 0%,
    rgba(63,169,201,0.7) 60%,
    rgba(13,27,42,0.95) 100%);
  transition: height 1100ms cubic-bezier(.5,.05,.3,1) 120ms;
}
.flood.rise .flood-wave  { height: 120%; }
.flood.fall .flood-wave  { height: 0%; }

.flood-text {
  position: absolute; left: 0; right: 0; top: 45%;
  text-align: center;
  font-size: 26px; letter-spacing: 0.5em;
  color: var(--paper);
  opacity: 0;
  transition: opacity 500ms ease;
  text-shadow: 0 2px 20px rgba(0,0,0,.7);
}
.flood.active .flood-text { opacity: 1; }

/* ---------- 顶部 ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  gap: 12px;
  background: linear-gradient(180deg, rgba(13,27,42,.92), rgba(13,27,42,0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.era-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(13,27,42,.72);
  border: 1px solid rgba(242,236,225,.18);
  backdrop-filter: blur(8px);
  font-size: 14px; letter-spacing: .08em;
  transition: all 600ms ease;
}
.era-badge.ancient {
  background: rgba(217,164,65,.16);
  border-color: rgba(217,164,65,.55);
  color: #f6dfa8;
}
.era-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--water);
  box-shadow: 0 0 8px var(--water);
  transition: all 600ms ease;
}
.era-badge.ancient .era-dot {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}

.stamina {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(13,27,42,.72);
  border: 1px solid rgba(242,236,225,.18);
  backdrop-filter: blur(8px);
  font-size: 12px;
}
.stamina-label { color: rgba(242,236,225,.6); }
.stamina-bar {
  width: 62px; height: 4px; border-radius: 2px;
  background: rgba(242,236,225,.18);
  overflow: hidden;
}
.stamina-bar i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--water), var(--gold));
  transition: width 400ms ease;
}
.stamina-num { min-width: 24px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 桥桩面板 ---------- */
.panel {
  position: absolute; top: 64px; right: 10px;
  z-index: 20;
  width: 214px;
  max-height: calc(100% - 170px);
  display: flex; flex-direction: column;
}
.panel-toggle {
  align-self: flex-end;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(242,236,225,.2);
  background: rgba(13,27,42,.8);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 13px; cursor: pointer;
  transition: all 300ms ease;
}
.panel-toggle:hover { border-color: var(--gold); color: #f6dfa8; }

.panel-body {
  margin-top: 8px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  border-radius: 14px;
  background: rgba(13,27,42,.88);
  border: 1px solid rgba(242,236,225,.14);
  backdrop-filter: blur(10px);
  transition: max-height 400ms ease, opacity 300ms ease;
}
.panel.open .panel-body {
  max-height: calc(100vh - 200px);
  opacity: 1;
  overflow-y: auto;
}
.panel-title { margin: 14px 16px 2px; font-size: 14px; letter-spacing: .1em; font-weight: 600; }
.panel-sub   { margin: 0 16px 10px; font-size: 11px; color: rgba(242,236,225,.5); }

.bridge-list { list-style: none; margin: 0; padding: 0 8px 12px; }
.bridge-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 200ms ease;
}
.bridge-item:hover { background: rgba(242,236,225,.07); }
.bridge-item .bi-dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--dust);
}
.bridge-item.exists .bi-dot { background: var(--water); box-shadow: 0 0 6px var(--water); }
.bridge-item .bi-name { font-size: 13px; flex: 1; }
.bridge-item .bi-river { font-size: 10px; color: rgba(242,236,225,.42); }

/* ---------- 底部 ---------- */
.bottombar {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 22px;
  gap: 14px;
  background: linear-gradient(0deg, rgba(13,27,42,.94), rgba(13,27,42,0));
  pointer-events: none;
}
.bottombar > * { pointer-events: auto; }

.avatar-info { display: flex; flex-direction: column; gap: 3px; }
.avatar-form { font-size: 14px; letter-spacing: .06em; }
.avatar-hint { font-size: 11px; color: rgba(242,236,225,.45); }

.dive-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 26px;
  border-radius: 999px;
  border: 1px solid rgba(63,169,201,.5);
  background: linear-gradient(135deg, rgba(63,169,201,.28), rgba(29,111,139,.4));
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 15px; letter-spacing: .12em;
  cursor: pointer;
  transition: all 500ms ease;
}
.dive-btn:hover { border-color: var(--water); box-shadow: 0 0 24px rgba(63,169,201,.35); }
.dive-btn.ancient {
  border-color: rgba(217,164,65,.6);
  background: linear-gradient(135deg, rgba(217,164,65,.26), rgba(120,80,20,.42));
}
.dive-btn.ancient:hover { box-shadow: 0 0 24px rgba(217,164,65,.4); }
.dive-icon {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--water);
  box-shadow: 0 0 8px var(--water);
  transition: all 500ms ease;
}
.dive-btn.ancient .dive-icon { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

/* ---------- 详情弹窗 ---------- */
.modal { position: absolute; inset: 0; z-index: 40; display: none; }
.modal.show { display: block; }
.modal-mask { position: absolute; inset: 0; background: rgba(6,12,20,.6); backdrop-filter: blur(3px); }

.modal-card {
  position: absolute; left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: 100%; max-width: 460px;
  max-height: 78%;
  /* 卡片本身不滚动，仅内部 .modal-scroll 滚动，
     以保证固定头部中的关闭按钮始终可见可点 */
  display: flex; flex-direction: column;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(180deg, #16283b, #0d1b2a);
  border-top: 1px solid rgba(242,236,225,.16);
  animation: slideUp 340ms cubic-bezier(.2,.8,.3,1);
}
@keyframes slideUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }

/* 固定头部：不随内容滚动 */
.modal-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px 22px;
  border-bottom: 1px solid rgba(242,236,225,.09);
}
.modal-close {
  flex: none;
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: rgba(242,236,225,.12);
  color: var(--text); font-size: 20px; line-height: 1;
  cursor: pointer;
  transition: background 200ms ease;
}
.modal-close:hover { background: rgba(242,236,225,.24); }
.modal-close:active { background: rgba(217,164,65,.35); }

.modal-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 22px 30px;
}

.modal-era {
  font-size: 11px; letter-spacing: .18em;
  color: var(--dust);
}
.modal-card.ancient .modal-era { color: var(--gold); }
.modal-name {
  margin: 0 0 4px; font-size: 23px; letter-spacing: .06em; font-weight: 600;
}
.modal-river {
  display: inline-block;
  margin-bottom: 16px; padding: 3px 10px;
  border-radius: 999px;
  background: rgba(63,169,201,.16);
  border: 1px solid rgba(63,169,201,.35);
  font-size: 11px; color: #9fd6e6;
}
.modal-section { margin-bottom: 14px; }
.modal-label {
  font-size: 11px; letter-spacing: .16em;
  color: rgba(242,236,225,.42);
  margin-bottom: 5px;
}
.modal-text { margin: 0; font-size: 14px; line-height: 1.75; color: rgba(242,236,225,.88); }
.modal-section-past { display: none; }
.modal-card.ancient .modal-section-past { display: block; }

.modal-story {
  margin-top: 6px; padding: 13px 15px;
  border-left: 2px solid var(--gold);
  background: rgba(217,164,65,.08);
  border-radius: 0 10px 10px 0;
  font-size: 13px; line-height: 1.8; color: #f0d9a8;
}

/* ---------- Key 门禁 ---------- */
.keygate {
  position: absolute; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #16283b, #060c14 70%);
  padding: 20px;
}
.keygate.hide { display: none; }
.keygate-card {
  width: 100%; max-width: 360px;
  padding: 30px 26px;
  border-radius: 18px;
  background: rgba(13,27,42,.9);
  border: 1px solid rgba(242,236,225,.14);
  text-align: center;
}
.keygate-card h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: .2em; font-weight: 600; }
.keygate-sub { margin: 0 0 20px; font-size: 12px; color: rgba(242,236,225,.5); }
#keyInput {
  width: 100%; padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(242,236,225,.2);
  background: rgba(0,0,0,.28);
  color: var(--text); font-size: 14px;
  outline: none;
}
#keyInput:focus { border-color: var(--water); }
#keySubmit {
  width: 100%; margin-top: 12px; padding: 13px;
  border-radius: 10px; border: none;
  background: linear-gradient(135deg, var(--water-deep), var(--water));
  color: #fff; font-size: 15px; letter-spacing: .1em;
  cursor: pointer;
}
.keygate-tip { margin: 16px 0 0; font-size: 11px; line-height: 1.7; color: rgba(242,236,225,.4); }
.keygate-tip code { background: rgba(242,236,225,.1); padding: 1px 5px; border-radius: 4px; }
.keygate-err { margin: 10px 0 0; font-size: 12px; color: #e8836b; min-height: 16px; }

/* ---------- 页内错误面板 ---------- */
.dbg {
  position: absolute;
  left: 12px; bottom: 88px;   /* 避开底部控制栏 */
  z-index: 55;                /* 高于弹窗(40)，低于 key 门禁(60) */
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 8px;
  font-size: 12px;
}
.dbg-toggle {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(242,236,225,.2);
  background: rgba(13,27,42,.82);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.dbg-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(242,236,225,.32);
  transition: all 300ms ease;
}
.dbg.has-error .dbg-dot {
  background: #e8836b;
  box-shadow: 0 0 8px #e8836b;
}
.dbg.has-error .dbg-toggle { border-color: rgba(232,131,107,.5); }

.dbg-panel {
  display: none;
  width: min(370px, calc(100vw - 24px));
  max-height: 42vh;
  flex-direction: column;
  border-radius: 12px;
  background: rgba(6,12,20,.94);
  border: 1px solid rgba(242,236,225,.16);
  overflow: hidden;
}
.dbg.open .dbg-panel { display: flex; }

.dbg-head {
  flex: none;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(242,236,225,.1);
}
.dbg-title {
  flex: 1;
  font-size: 11px; letter-spacing: .1em;
  color: rgba(242,236,225,.55);
}
.dbg-btn {
  border: 1px solid rgba(242,236,225,.18);
  background: rgba(242,236,225,.08);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.dbg-btn:hover { background: rgba(242,236,225,.18); }

.dbg-list {
  flex: 1 1 auto;
  list-style: none; margin: 0; padding: 6px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.dbg-item {
  padding: 6px 8px; margin-bottom: 4px;
  border-radius: 6px;
  background: rgba(232,131,107,.1);
  border-left: 2px solid #e8836b;
}
.dbg-item.dbg-warn {
  background: rgba(217,164,65,.1);
  border-left-color: var(--gold);
}
.dbg-item-head {
  font-size: 10px; letter-spacing: .04em;
  color: rgba(242,236,225,.45);
  margin-bottom: 3px;
}
.dbg-item-msg {
  font-size: 11.5px; line-height: 1.6;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.dbg-empty {
  padding: 12px; text-align: center;
  color: rgba(242,236,225,.32); font-size: 11px;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 420px) {
  .panel { width: 178px; }
  .dive-btn { padding: 12px 20px; font-size: 14px; }
  .avatar-hint { display: none; }
}
