/* 玄机道长 Web —— 墨金朱砂主题 */
:root {
  --ink: #1a1814;
  --ink-light: #282520;
  --paper: #f2e9d4;
  --paper-dim: #c9c0a8;
  --gold: #c9a227;
  --cinnabar: #c24428;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--ink);
  color: var(--paper);
  font-family: "Songti SC", "Noto Serif SC", "STSong", serif;
  max-width: 520px;
  margin: 0 auto;
  overscroll-behavior: none;
}

/* ===== 开屏 ===== */
#opening {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at 50% 38%, #25211a 0%, var(--ink) 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; cursor: pointer; transition: opacity 1s, transform 1s;
}
#opening.closed { opacity: 0; transform: scale(1.06); pointer-events: none; }
.bagua-ring {
  position: absolute; width: min(86vw, 380px); height: min(86vw, 380px);
  border: 0.8px solid rgba(201, 162, 39, .22); border-radius: 50%;
  animation: spin 240s linear infinite;
}
.bagua-ring::before {
  content: ''; position: absolute; inset: 18px;
  border: 0.6px dashed rgba(201, 162, 39, .12); border-radius: 50%;
}
.bagua-ring i {
  position: absolute; left: 50%; top: 50%; font-style: normal;
  color: rgba(201, 162, 39, .5); font-size: 19px;
  transform: translate(-50%, -50%) rotate(var(--r)) translateY(calc(min(43vw, 190px) * -1)) rotate(calc(var(--r) * -1));
}
@keyframes spin { to { transform: rotate(360deg); } }
.glow-line { display: flex; justify-content: center; gap: 2px; }
.glow-char {
  font-size: 27px; font-weight: 500; opacity: 0;
  animation: glowIn .55s ease-out forwards;
}
@keyframes glowIn {
  0% { opacity: 0; transform: scale(1.7); filter: blur(8px); text-shadow: none; }
  60% { opacity: 1; transform: scale(1); filter: blur(0); text-shadow: 0 0 14px var(--glow), 0 0 30px var(--glow); }
  100% { opacity: 1; transform: scale(1); text-shadow: 0 0 6px var(--glow); }
}
#opening-quote, .oq { display: flex; flex-direction: column; gap: 10px; z-index: 1; }
#opening-author, .oa { color: var(--paper-dim); font-size: 14px; opacity: 0; transition: opacity 1.2s; z-index: 1; }
#opening-hint, .oh {
  position: absolute; bottom: 64px; letter-spacing: 6px; font-size: 13px;
  color: rgba(201, 162, 39, .85); opacity: 0; transition: opacity 1.4s;
}
#opening-author.shown, #opening-hint.shown, .oa.shown, .oh.shown { opacity: 1; }
/* 香灰余烬粒子（纯 CSS） */
.ember { position: absolute; bottom: -8px; width: 4px; height: 4px; border-radius: 50%;
  background: radial-gradient(circle, rgba(230,190,90,.95), transparent 70%);
  animation: rise linear infinite; }
@keyframes rise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  12% { opacity: .9; }
  100% { transform: translateY(-92vh) translateX(var(--sway)); opacity: 0; }
}

/* ===== 布局 ===== */
.page { display: none; padding: 12px 14px calc(74px + env(safe-area-inset-bottom)); min-height: 100dvh; }
.page.active { display: block; }
.card {
  background: var(--ink-light); border: 0.8px solid rgba(201, 162, 39, .25);
  border-radius: 14px; padding: 15px; margin-bottom: 13px;
}
.seal {
  display: inline-block; background: var(--cinnabar); color: var(--paper);
  font-size: 12px; font-weight: 700; padding: 4px 6px; border-radius: 3px; margin-right: 8px;
}
h1.page-title { font-size: 17px; letter-spacing: 5px; text-align: center; padding: 12px 0 14px; font-weight: 600; }
.dim { color: var(--paper-dim); font-size: 13px; }
.gold { color: var(--gold); }
.disclaimer { font-size: 11px; color: rgba(201, 192, 168, .55); line-height: 1.7; padding: 2px 4px 10px; }

/* ===== 底部 tab ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; display: flex; z-index: 50;
  background: #14120e; box-shadow: 0 -6px 18px rgba(0, 0, 0, .45);
  border-top: 0.8px solid rgba(201, 162, 39, .28);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: none; color: var(--paper-dim);
  font-family: inherit; font-size: 11px; padding: 8px 0 7px; cursor: pointer;
}
.tabbar button span {
  display: block; font-size: 20px; margin: 0 auto 3px; width: 30px; height: 30px;
  line-height: 28px; border: 1px solid transparent; border-radius: 7px; font-weight: 600;
}
.tabbar button.active { color: var(--gold); }
.tabbar button.active span {
  border-color: rgba(201, 162, 39, .55); background: rgba(201, 162, 39, .08);
  box-shadow: 0 0 10px rgba(201, 162, 39, .25);
}

/* ===== 今日 ===== */
.banner { border-radius: 14px; overflow: hidden; margin-bottom: 13px; position: relative; }
.banner img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.banner .overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 13px; background: linear-gradient(transparent 30%, rgba(20, 18, 14, .92));
}
.banner h2 { font-size: 21px; font-weight: 600; }
.yi-ji { display: flex; gap: 10px; margin-top: 8px; font-size: 14px; line-height: 1.6; }
.yi-ji b { flex-shrink: 0; }
.hex-wrap { display: flex; gap: 20px; align-items: center; }
.hex-lines { display: flex; flex-direction: column; gap: 6px; }
.hex-line { display: flex; gap: 6px; opacity: 0; transform: translateX(-10px); animation: lineIn .4s ease-out forwards; position: relative; }
.hex-line i { display: block; height: 8px; border-radius: 2px; background: var(--gold); }
.hex-line.yang i { width: 64px; }
.hex-line.yin i { width: 28px; }
.hex-line.moving::after { content: ''; position: absolute; right: -13px; top: 1px; width: 6px; height: 6px; border-radius: 50%; background: var(--cinnabar); }
@keyframes lineIn { to { opacity: 1; transform: none; } }
.master-text { font-size: 15px; line-height: 1.9; min-height: 60px; }

/* ===== 罗盘 ===== */
#luopan {
  width: min(100%, calc(100dvh - 320px));
  aspect-ratio: 1; display: block; margin: 0 auto;
}
.compass-needle-mark { text-align: center; color: var(--cinnabar); font-size: 15px; margin-bottom: -8px; text-shadow: 0 0 6px rgba(194, 68, 40, .8); }
.compass-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn-gold {
  background: var(--gold); color: var(--ink); border: none; border-radius: 99px;
  font-family: inherit; font-weight: 700; font-size: 15px; padding: 10px 20px; cursor: pointer;
  box-shadow: 0 0 12px rgba(201, 162, 39, .35);
}
.btn-ghost {
  background: rgba(40, 37, 32, .9); color: var(--paper); border: 0.7px solid rgba(201, 162, 39, .4);
  border-radius: 99px; font-family: inherit; font-size: 13px; padding: 9px 14px; cursor: pointer;
}
input[type=range] { width: 100%; accent-color: var(--gold); }
#lock-panel, #vein-panel {
  position: fixed; left: 50%; transform: translate(-50%, 105%); bottom: 0; width: 100%; max-width: 520px;
  background: #211e18; border-radius: 18px 18px 0 0; border-top: 1px solid rgba(201, 162, 39, .4);
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); z-index: 60; transition: transform .45s cubic-bezier(.2, .8, .2, 1);
  max-height: 72vh; overflow-y: auto;
}
#lock-panel.shown, #vein-panel.shown { transform: translate(-50%, 0); }
#lock-zuoxiang { font-size: 32px; font-weight: 700; color: var(--gold); text-shadow: 0 0 14px rgba(201, 162, 39, .5); text-align: center; margin: 6px 0; }
.panel-close { float: right; background: none; border: none; color: var(--paper-dim); font-size: 19px; cursor: pointer; }

/* ===== 八字 ===== */
.form-row { margin-bottom: 12px; }
.form-row label.head { display: block; font-size: 13px; color: var(--paper-dim); margin-bottom: 6px; }
select, input[type=datetime-local] {
  background: var(--ink); color: var(--paper); border: 0.7px solid rgba(201, 162, 39, .35);
  border-radius: 8px; padding: 9px; font-family: inherit; font-size: 15px;
}
.radio-row { display: flex; gap: 14px; font-size: 15px; }
.privacy-box { display: flex; gap: 10px; align-items: flex-start; font-size: 12px; color: var(--paper-dim); line-height: 1.7; }
.privacy-box b { color: var(--paper); font-size: 14px; display: block; }
#bazi-pillars { display: flex; gap: 8px; }
.pillar {
  flex: 1; background: var(--ink); border: 0.7px solid rgba(201, 162, 39, .25); border-radius: 10px;
  text-align: center; padding: 10px 2px; opacity: 0; transform: perspective(500px) rotateY(80deg);
  animation: flipIn .5s ease-out forwards;
}
.pillar.daymaster { border-color: rgba(201, 162, 39, .7); }
@keyframes flipIn { to { opacity: 1; transform: none; } }
.pillar small { display: block; font-size: 10px; color: var(--paper-dim); }
.pillar b { display: block; font-size: 25px; line-height: 1.25; }
.pillar .nayin { margin-top: 3px; transform: scale(.85); }
.bar-row { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; font-size: 14px; }
.bar-row .bar { flex: 1; height: 9px; background: var(--ink); border-radius: 99px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; width: 0; border-radius: 99px; transition: width 1s ease-out; }
.bar-row em { font-style: normal; font-size: 11px; color: var(--paper-dim); width: 26px; text-align: right; }
#bazi-goals { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
#bazi-goals button {
  background: var(--ink); color: var(--paper); border: 0.7px solid rgba(201, 162, 39, .4);
  border-radius: 99px; font-family: inherit; font-size: 14px; padding: 8px 16px; cursor: pointer;
}
#bazi-goals button.on { background: var(--gold); color: var(--ink); font-weight: 700; }
.burn { background: none; border: none; color: var(--cinnabar); font-family: inherit; font-size: 13px; cursor: pointer; margin-top: 10px; }

/* ===== 龙脉 ===== */
#page-vein { padding: 0; }
#veinmap { width: 100%; height: calc(100dvh - 58px - env(safe-area-inset-bottom)); background: #111; }
.vein-controls {
  position: fixed; bottom: calc(64px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; z-index: 45;
}
.acu-pulse { position: relative; width: 18px; height: 18px; }
.acu-pulse span {
  position: absolute; inset: 4px; border-radius: 50%; background: var(--cinnabar);
  box-shadow: 0 0 8px var(--cinnabar);
}
.acu-pulse::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--cinnabar); animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(.5); opacity: .9; } 100% { transform: scale(2.4); opacity: 0; } }
.partner-slot {
  border: 1px dashed rgba(201, 162, 39, .5); border-radius: 12px; padding: 12px;
  display: flex; gap: 10px; align-items: center; margin-top: 12px; font-size: 12px; color: var(--paper-dim);
}
.leaflet-container { font-family: inherit; }
/* Leaflet 控件入墨：白底系统样式与主题违和 */
.leaflet-control-layers {
  background: rgba(26, 24, 20, .94) !important;
  color: var(--paper) !important;
  border: 0.8px solid rgba(201, 162, 39, .45) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5) !important;
}
.leaflet-control-layers-toggle {
  filter: invert(.85) sepia(.4) saturate(2) hue-rotate(10deg);
}
.leaflet-control-layers label { color: var(--paper); font-size: 13px; }
.leaflet-control-layers input { accent-color: var(--gold); }
.leaflet-control-attribution {
  background: rgba(20, 18, 14, .75) !important;
  color: rgba(214, 205, 180, .75) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: rgba(201, 162, 39, .85) !important; }
