:root { --bg: #0f1428; --card: #1a2140; --ink: #f1ecdd; --muted: #a9b0c8; --gold: #d9c08a; --west: #7fb3ff; --east: #ffb27f; --danger: #ff8a8a; --radius: 16px; }
* { box-sizing: border-box; }
html { background: #04060d; }
html, body { margin: 0; color: var(--ink); font-family: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; }
main { max-width: 720px; margin: 0 auto; padding: 16px 16px 60px; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,.08); position: sticky; top: 0; background: rgba(4,6,13,.55); backdrop-filter: blur(6px); z-index: 5; }
.nav-btn { background: none; border: 0; color: var(--gold); font-size: 15px; padding: 6px 8px; cursor: pointer; }
h1 { font-size: 28px; margin: 12px 0 4px; } h2 { font-size: 22px; margin: 8px 0; } h3 { font-size: 17px; color: var(--gold); margin: 16px 0 8px; }
.lead, .hint { color: var(--muted); font-size: 14px; line-height: 1.6; }
form label { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
input, select { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid #3a4470; background: #141a33; color: var(--ink); font-size: 16px; margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; } .row > span { color: var(--muted); font-size: 14px; min-width: 64px; }
.row.three { align-items: flex-end; } .row.three label { flex: 1; margin: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid #3a4470; background: #141a33; color: var(--muted); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; }
.chip.active { border-color: var(--gold); color: var(--gold); }
.check { display: flex; align-items: center; gap: 8px; } .check input { width: auto; margin: 0; }
.btn { display: inline-block; border: 1px solid #3a4470; background: #141a33; color: var(--ink); border-radius: 12px; padding: 10px 16px; font-size: 15px; cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--gold); color: #1a1408; border-color: var(--gold); font-weight: 600; width: 100%; margin-top: 18px; }
.btn.danger { color: var(--danger); } .btn[disabled] { opacity: .5; pointer-events: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.result-head .derived { display: flex; flex-wrap: wrap; gap: 6px; } .derived span { background: #141a33; border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.derived .stale { color: var(--danger); border: 1px solid var(--danger); }
.tracks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.track { background: var(--card); border-radius: var(--radius); padding: 14px; border-top: 3px solid var(--west); min-height: 150px; }
.track.east { border-top-color: var(--east); } .track .kicker { font-size: 12px; color: var(--muted); } .track .big { font-size: 30px; font-weight: 700; margin: 6px 0; }
.track .flags { font-size: 12px; color: var(--gold); } .track .note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.card-stage { display: flex; flex-direction: column; align-items: center; margin: 22px 0 8px; }
.flip { width: 210px; height: 364px; perspective: 1200px; cursor: pointer; position: relative; }
.flip .face { position: absolute; inset: 0; backface-visibility: hidden; transition: transform .8s cubic-bezier(.2,.8,.2,1); border-radius: 14px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.flip .face img { width: 100%; height: 100%; display: block; }
.flip .front { transform: rotateY(180deg); } .flip.open .back { transform: rotateY(180deg); } .flip.open .front { transform: rotateY(360deg); box-shadow: 0 0 40px rgba(217,192,138,.45); }
.flip.open { animation: float 4s ease-in-out infinite; } @keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.card-caption { text-align: center; margin-top: 12px; min-height: 48px; } .card-caption .title { font-size: 20px; color: var(--gold); } .card-caption .tag { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 16px 0 8px; } .tab { border: 0; background: #141a33; color: var(--muted); padding: 8px 14px; border-radius: 999px; white-space: nowrap; cursor: pointer; } .tab.active { color: var(--gold); border: 1px solid var(--gold); }
.panel, .relation-box { background: var(--card); border-radius: var(--radius); padding: 14px; font-size: 14px; line-height: 1.7; }
.panel .item { padding: 8px 0; border-bottom: 1px solid #2c365e; } .panel .item:last-child { border-bottom: 0; }
.tag { display: inline-block; background: #2c365e; border-radius: 6px; padding: 1px 6px; font-size: 11px; margin-right: 6px; color: var(--gold); }
.quote { color: #e6dcc0; font-family: serif; } .note { color: var(--muted); font-size: 12px; } .missing { color: var(--danger); }
.interpretation { background: #141a33; border-radius: var(--radius); padding: 14px; margin-top: 14px; white-space: pre-wrap; line-height: 1.8; font-size: 14px; position: relative; }
.interpretation.loading { color: var(--muted); } .source-tag { display: block; margin-top: 10px; font-size: 12px; color: var(--muted); }
.list .item-row { display: flex; justify-content: space-between; align-items: center; background: var(--card); border-radius: 12px; padding: 12px; margin-bottom: 8px; cursor: pointer; } .item-row small { color: var(--muted); display: block; }
.item-row .del { color: var(--danger); padding: 4px 8px; }
.empty { color: var(--muted); padding: 12px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.gallery .g { background: var(--card); border-radius: 12px; padding: 8px; text-align: center; font-size: 12px; } .gallery img { width: 100%; border-radius: 8px; } .gallery .niu { outline: 1px dashed var(--gold); }
.relation-box .pair { font-size: 30px; color: var(--gold); text-align: center; margin: 6px 0 12px; } .relation-box .dir { padding: 8px; background: #141a33; border-radius: 10px; margin: 6px 0; }
#relation-picker { background: var(--card); border-radius: var(--radius); padding: 12px; margin-top: 10px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #2c365e; color: var(--ink); padding: 10px 16px; border-radius: 999px; font-size: 14px; pointer-events: none; z-index: 20; }
.modal { position: fixed; inset: 0; background: rgba(2,3,8,.82); backdrop-filter: blur(4px); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; padding: 16px 16px calc(120px + env(safe-area-inset-bottom)); }
.modal-body { max-width: 92vw; text-align: center; } .modal-body img { max-width: 100%; max-height: calc(100vh - 190px); display: block; margin: 0 auto; border-radius: 10px; box-shadow: 0 0 60px rgba(217,192,138,.18); }
.modal-actions, .ractions { position: fixed; left: 0; right: 0; bottom: calc(28px + env(safe-area-inset-bottom)); display: flex; gap: 12px; justify-content: center; padding: 0 16px; }
.modal-actions .btn, .ractions .btn { width: auto; min-width: 128px; margin: 0; } .save-hint { margin: 8px 0 0; font-size: 12px; }
#about h3 { margin-top: 18px; } #about p { font-size: 13px; color: var(--muted); line-height: 1.7; } #about .src { color: #cfc6a8; }
@media (max-width: 480px) { .tracks { grid-template-columns: 1fr; } .flip { width: 180px; height: 312px; } }
[hidden] { display: none !important; }

/* 星宿守护卡：画芯 + 程序叠加的星官星图、边框与宿名（画芯不含文字；圆角约为宽的 6%，即素材规格的 72/1200） */
.flip .face { border-radius: calc(210px * .06); background: #08191c; }
.flip .face img.art, .flip .face img.frame { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.flip .front .stars { position: absolute; left: 12%; top: 7%; width: 76%; height: 19%; pointer-events: none; }
.flip .front .xname { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 10px 12px; text-align: center; pointer-events: none;
  background: linear-gradient(to top, rgba(8,12,24,.85), rgba(8,12,24,0)); }
.flip .front .xname b { display: block; font-size: 26px; letter-spacing: .3em; color: var(--gold); text-shadow: 0 0 12px rgba(255,217,143,.6); }
.flip .front .xname span { font-size: 11px; color: #e8e2d0; letter-spacing: .15em; opacity: .85; }
.gallery .g img { aspect-ratio: 1200 / 2080; object-fit: cover; background: #08191c; }
@media (prefers-reduced-motion: reduce) { .flip .face { transition: none; } .flip.open { animation: none; } }

/* ---- 星空背景与飞牌揭晓（fx.js） ---- */
#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; display: block; }
.track, .panel, .relation-box, .gallery .g, .item-row { background: rgba(20,26,52,.62) !important; backdrop-filter: blur(6px); }
.home { min-height: calc(100vh - 110px); display: flex; align-items: center; justify-content: center; }
.glass { width: 100%; max-width: 440px; padding: 22px 20px 18px; border-radius: 20px; background: rgba(14,18,38,.55); border: 1px solid rgba(217,192,138,.22);
  box-shadow: 0 20px 60px rgba(0,0,0,.45), inset 0 0 40px rgba(120,110,200,.08); backdrop-filter: blur(10px); transition: opacity .6s, transform .6s, filter .6s; }
.glass h1 { text-align: center; letter-spacing: .25em; color: var(--gold); text-shadow: 0 0 20px rgba(255,217,143,.35); margin-top: 0; }
.glass .lead { text-align: center; }
.glass.fading { opacity: 0; transform: scale(.96) translateY(10px); filter: blur(6px); pointer-events: none; }
.ritual { position: fixed; inset: 0; z-index: 40; overflow-y: auto; }
.ritual .deck { position: fixed; inset: 0; overflow: hidden; perspective: 900px; perspective-origin: 50% 45%; transform-style: preserve-3d; }
/* 飞来的牌：平躺、牌背朝外，远处只见一条线，飞近才看到牌背；飞近时一道金色反光扫过 */
.ritual .fly { position: absolute; left: 50%; top: 45%; border-radius: 8px; overflow: hidden; backface-visibility: hidden; will-change: transform, opacity;
  box-shadow: 0 0 22px rgba(255,217,143,.45), 0 0 60px rgba(150,170,255,.18); }
.ritual .fly img { display: block; width: 100%; height: 100%; }
.sheen { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; background-size: 300% 100%; background-position: 100% 0;
  background-image: linear-gradient(105deg, rgba(255,236,190,0) 40%, rgba(255,236,190,.75) 50%, rgba(255,236,190,0) 60%); }
.rcard.ready .sheen { animation: sheen 4.2s ease-in-out 1s infinite; }
@keyframes sheen { 0% { background-position: 100% 0; } 30%, 100% { background-position: 0% 0; } }
.ritual .skip { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 2; background: rgba(0,0,0,.35); color: var(--muted); border: 1px solid rgba(255,255,255,.15); border-radius: 999px; padding: 6px 14px; }
.ritual .reveal { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 8vh 16px calc(110px + env(safe-area-inset-bottom)); opacity: 0; pointer-events: none; }
.ritual .reveal.shown { opacity: 1; pointer-events: auto; }
.rcard { position: relative; width: min(280px, 62vw); aspect-ratio: 1200 / 2080; perspective: 1400px; outline: none; }
.rcard .rinner { z-index: 1; }
.rcard.ready { cursor: pointer; animation: beckon 2.2s ease-in-out infinite; }
.rcard.ready .face { box-shadow: 0 0 28px rgba(255,217,143,.45), 0 12px 36px rgba(0,0,0,.6); }
.rcard:focus-visible .face { outline: 2px solid var(--gold); outline-offset: 4px; }
@keyframes beckon { 0%, 100% { transform: translateY(0); filter: drop-shadow(0 0 8px rgba(255,217,143,.25)); } 50% { transform: translateY(-6px); filter: drop-shadow(0 0 22px rgba(255,217,143,.6)); } }
.rhint { margin: 4px 0; font-size: 14px; letter-spacing: .2em; color: var(--gold); opacity: .85; animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.rinner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.2,.8,.2,1); }
.rinner.flipped { transform: rotateY(180deg); }
.rinner .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 6%/3.5%; overflow: hidden; background: #08191c;
  box-shadow: 0 0 50px rgba(217,192,138,.35), 0 18px 50px rgba(0,0,0,.6); }
.rinner .front { transform: rotateY(180deg); }
.rinner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.rinner .rstars { position: absolute; left: 12%; top: 7%; width: 76%; height: 19%; }
.rinner .rname { position: absolute; left: 0; right: 0; bottom: 0; padding: 50px 10px 16px; text-align: center; background: linear-gradient(to top, rgba(8,12,24,.85), rgba(8,12,24,0)); }
.rinner .rname b { display: block; font-size: 30px; letter-spacing: .3em; color: var(--gold); text-shadow: 0 0 14px rgba(255,217,143,.6); }
.rinner .rname span { font-size: 12px; letter-spacing: .15em; color: #e8e2d0; }
.rinfo { margin-top: 22px; text-align: center; max-width: 420px; }
.rline { margin: 6px 0; opacity: 0; transform: translateY(10px); filter: blur(4px); animation: rise .8s ease-out forwards; }
.rline.title { font-size: 24px; color: var(--gold); letter-spacing: .12em; text-shadow: 0 0 16px rgba(255,217,143,.35); }
.rline.tagline { font-size: 14px; color: var(--muted); } .rline.west { color: var(--west); font-size: 16px; } .rline.east { color: var(--east); font-size: 16px; }
.rline.small { font-size: 12px; color: var(--muted); }
@keyframes rise { to { opacity: 1; transform: none; filter: none; } }
.ractions { opacity: 0; transition: opacity .6s; pointer-events: none; } .ractions.shown { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .rline { animation-duration: .01s; } .rinner, .glass { transition: none; } .rcard.ready, .rhint, .rcard.ready .sheen { animation: none; } }
body { background: transparent; }
