/* ===== 数字游戏 · 移动优先 v2 ===== */
:root {
  --bg: #0E0B1E;
  --bg2: #171233;
  --card: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
  --text: #F4F1FF;
  --dim: #9B93C7;
  --gold: #F5C34B;
  --pink: #FF7AC2;
  --green: #5CE1A6;
  --dark: #241A00;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% 0%, var(--bg2) 0%, var(--bg) 60%, #090613 100%);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  overflow: hidden;
  user-select: none;
}
.app { height: 100%; height: 100dvh; position: relative; }

/* 屏幕切换 */
.screen {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: none; flex-direction: column;
  padding: 0 20px calc(20px + env(safe-area-inset-bottom));
  overflow: hidden;
}
.screen.active { display: flex; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ===== 顶栏 ===== */
.bar { display: flex; align-items: center; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 0 14px; }
.btn-back {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font-size: 26px; line-height: 1; cursor: pointer; flex: none;
}
.btn-back:active { transform: scale(.92); }
.bar-title { font-size: 18px; font-weight: 700; letter-spacing: .1em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-badge { font-size: 13px; color: var(--dim); white-space: nowrap; }

/* ===== 首页 ===== */
#screen-home { justify-content: center; align-items: center; text-align: center; }
.home-inner { display: flex; flex-direction: column; align-items: center; gap: 0; }
.logo-box { margin-bottom: 7vh; animation: float 4s ease-in-out infinite; }
.logo-dice { font-size: clamp(64px, 22vw, 110px); filter: drop-shadow(0 10px 30px rgba(245,195,75,.35)); cursor: pointer; }
.logo-title {
  font-size: clamp(40px, 13vw, 64px); font-weight: 800; letter-spacing: .08em; margin-top: 8px;
  background: linear-gradient(120deg, var(--gold), var(--pink) 60%, #8F7BFF);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo-title span { display: block; font-size: .5em; letter-spacing: .5em; margin-top: 4px; }
.logo-sub { color: var(--dim); letter-spacing: .3em; font-size: 14px; margin-top: 12px; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.home-hint { color: var(--dim); line-height: 1.8; font-size: 15px; margin-bottom: 4vh; }

/* 主按钮 */
.btn-main {
  width: min(78vw, 340px); height: 64px; border: none; border-radius: 999px;
  background: linear-gradient(120deg, var(--gold), #FF9D5C 50%, var(--pink));
  color: var(--dark); font-size: 26px; font-weight: 800; letter-spacing: .4em; text-indent: .4em;
  box-shadow: 0 12px 40px rgba(255, 154, 92, .4), inset 0 -4px 10px rgba(0,0,0,.18);
  cursor: pointer; transition: transform .15s ease, box-shadow .2s ease;
}
.btn-main:hover { transform: translateY(-2px); box-shadow: 0 16px 50px rgba(255,154,92,.5); }
.btn-main:active { transform: scale(.96); }
.btn-main.small { height: 54px; font-size: 18px; width: min(72vw, 300px); letter-spacing: .25em; }
.btn-main.ghost2 {
  background: linear-gradient(120deg, rgba(245,195,75,.9), rgba(255,122,194,.85));
  box-shadow: 0 10px 32px rgba(255,122,194,.3);
}
.btn-ghost {
  height: 50px; border-radius: 999px; border: 1px dashed rgba(245,195,75,.5); background: rgba(245,195,75,.08);
  color: var(--gold); font-size: 15px; font-weight: 700; letter-spacing: .08em; cursor: pointer;
  transition: transform .15s ease, background .2s ease;
  width: min(72vw, 300px); align-self: center;
}
.btn-ghost:active { transform: scale(.96); }
.btn-ghost.now { border-color: rgba(92,225,166,.5); background: rgba(92,225,166,.08); color: var(--green); }
.home-foot { position: absolute; bottom: calc(30px + env(safe-area-inset-bottom)); color: var(--dim); font-size: 13px; letter-spacing: .05em; }

/* ===== 选玩法 ===== */
.pick-grid { display: flex; flex-direction: column; gap: 13px; padding-top: 4vh; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; min-height: 0; }
.pick-card {
  display: flex; align-items: center; gap: 16px; text-align: left;
  padding: 17px 20px; border-radius: 22px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); cursor: pointer; transition: transform .15s ease, background .2s ease;
  animation: cardIn .45s cubic-bezier(.2,.9,.3,1.2) both;
}
.pick-card:hover { background: rgba(255,255,255,.1); transform: translateY(-2px); }
.pick-card:active { transform: scale(.97); }
.pick-icon { font-size: 36px; filter: drop-shadow(0 4px 12px rgba(143,123,255,.5)); }
.pick-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pick-name { font-size: 19px; font-weight: 800; }
.pick-desc { font-size: 13px; color: var(--dim); }
.pick-go { margin-left: auto; font-size: 26px; color: var(--dim); }

/* ===== 输入 ===== */
.input-card { padding-top: 2vh; display: flex; flex-direction: column; gap: 12px; flex: 1; overflow-y: auto; }
.input-hero { font-size: 22px; font-weight: 800; letter-spacing: .03em; line-height: 1.5; text-align: center; margin: 1.5vh 0 2.5vh; }
.input-hero::after { content: ""; display: block; width: 48px; height: 4px; border-radius: 2px; margin: 12px auto 0; background: linear-gradient(90deg, var(--gold), var(--pink)); }
.picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.picker {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; transition: transform .15s ease, border-color .2s ease;
}
.picker:active { transform: scale(.97); }
.picker:focus-within { border-color: var(--gold); }
.picker-label { font-size: 12px; color: var(--dim); letter-spacing: .15em; padding: 2px 0 0 4px; }
.picker-label em { font-style: normal; color: var(--gold); font-size: 11px; }
.picker-select {
  width: 100%; background: transparent; color: var(--text); border: none; outline: none;
  font-size: 21px; font-weight: 800; appearance: none; -webkit-appearance: none;
  padding: 4px 22px 4px 2px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23F5C34B' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 4px center;
}
.picker-select option { background: #171233; color: var(--text); font-weight: 600; }

/* 性别开关 + 名字 */
.opt-row { display: flex; align-items: center; gap: 12px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.seg-btn {
  padding: 10px 22px; background: transparent; color: var(--dim); border: none;
  font-size: 15px; font-weight: 700; cursor: pointer; letter-spacing: .1em;
}
.seg-btn[aria-pressed="true"] { background: linear-gradient(120deg, var(--gold), var(--pink)); color: var(--dark); }
.name-input {
  flex: 1; min-width: 0; height: 44px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 15px; padding: 0 18px; outline: none;
  -webkit-user-select: text; user-select: text; font-family: inherit;
}
.name-input:focus { border-color: var(--gold); }
.name-input::placeholder { color: var(--dim); }

.input-tip { color: var(--dim); font-size: 13px; margin: 0 auto; }

/* ===== 结果页 ===== */
.result-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 30px; }
.result-lead {
  background: linear-gradient(135deg, rgba(245,195,75,.22), rgba(255,122,194,.16));
  border: 1px solid rgba(245,195,75,.45); border-radius: 20px;
  padding: 18px 18px 16px; margin: 8px 0 12px;
  font-size: 18px; font-weight: 700; line-height: 1.7;
  box-shadow: 0 4px 18px rgba(245,195,75,.10);
  animation: leadIn .5s cubic-bezier(.2,.9,.3,1.2) both;
  -webkit-user-select: text; user-select: text;
}
.result-lead b { color: var(--gold); }
@keyframes leadIn { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
.result-story {
  background: linear-gradient(135deg, rgba(245,195,75,.12), rgba(255,122,194,.1));
  border: 1px solid rgba(245,195,75,.3); border-radius: 20px;
  padding: 18px; margin: 8px 0 18px; font-size: 16px; line-height: 1.85;
  cursor: pointer;
  -webkit-user-select: text; user-select: text;
}
.result-story b { color: var(--gold); }
.cards { display: flex; flex-direction: column; gap: 14px; }
.card {
  border-radius: 22px; padding: 18px 20px; border: 1px solid var(--line);
  background: var(--card); position: relative; overflow: hidden;
  animation: cardIn .5s cubic-bezier(.2,.9,.3,1.2) both;
  -webkit-user-select: text; user-select: text;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(26px) rotate(2deg) scale(.96); } to { opacity: 1; transform: none; } }
.card::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 6px; background: var(--cc); }
.card-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.card-title { font-size: 13px; color: var(--dim); letter-spacing: .08em; display: inline-flex; align-items: center; gap: 6px; }
.card-group {
  font-size: 10px; color: var(--cc); border: 1px solid var(--cc); opacity: .85;
  border-radius: 999px; padding: 1px 8px; letter-spacing: .05em; flex: none;
}
.card.g-核心::before { background: linear-gradient(var(--cc), var(--cc)) !important; }
.card-number { font-size: 26px; font-weight: 900; color: var(--cc); margin-left: auto; text-align: right; }
.card-keyword { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.card-keyword b, .card-desc b { color: var(--cc); }
.card-desc { font-size: 14px; color: var(--dim); line-height: 1.7; }
.card-plain {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px dashed rgba(255,255,255,.16);
  font-size: 13px; line-height: 1.7; color: rgba(244,241,255,.8);
}
.card-plain::before { content: "💡 白话："; color: var(--gold); font-weight: 700; }
.card-extra { font-size: 12.5px; color: var(--dim); line-height: 1.65; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; opacity: .85; }

/* 趣味尾注 */
.fun-tip {
  margin-top: 14px; padding: 10px 14px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,206,90,.14), rgba(255,120,160,.10));
  border: 1px solid rgba(255,206,90,.30);
  font-size: 13px; line-height: 1.7; color: rgba(255,233,180,.95);
  text-align: center;
}

/* 断语溯源窗 */
.verdict-panel { margin-top: 18px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); overflow: hidden; }
.vp-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; background: transparent; border: none; color: var(--text);
  font-size: 15px; font-weight: 700; cursor: pointer; letter-spacing: .05em;
}
.vp-body { max-height: 0; overflow: hidden; transition: max-height .4s ease; }
.vp-body.open { max-height: 60vh; overflow-y: auto; }
.vp-body { padding: 0 18px; }
.vp-body.open { padding: 0 18px 14px; }
.verdict-item { border-top: 1px dashed var(--line); padding: 12px 0; }
.verdict-item:first-of-type { border-top: none; }
.v-title { font-size: 14px; font-weight: 800; color: var(--gold); margin-bottom: 4px; }
.v-text { font-size: 13.5px; color: var(--dim); line-height: 1.7; }
.v-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.rule-tag {
  font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--green);
  border: 1px solid rgba(92,225,166,.4); background: rgba(92,225,166,.08);
  border-radius: 999px; padding: 2px 10px;
}
.v-src { font-size: 11.5px; color: var(--dim); }

.result-actions { margin-top: 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.result-foot { text-align: center; color: var(--dim); font-size: 11.5px; margin-top: 18px; letter-spacing: .05em; }

/* toast */
.toast, .toast.achieve {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(80px);
  background: rgba(30, 24, 60, .95); border: 1px solid var(--line); color: var(--text);
  padding: 13px 24px; border-radius: 999px; font-size: 14px; z-index: 19;
  transition: transform .3s ease; pointer-events: none; max-width: 84vw; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.achieve {
  bottom: 90px; background: linear-gradient(120deg, rgba(245,195,75,.95), rgba(255,122,194,.95));
  color: var(--dark); font-weight: 800; border: none;
}

/* 分享弹层 */
.modal {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 30; background: rgba(5, 3, 16, .85);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .25s ease; backdrop-filter: blur(6px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(86vw, 380px); border-radius: 26px; padding: 18px;
  background: linear-gradient(160deg, #2E1F66, #171233);
  border: 1px solid rgba(245,195,75,.35); text-align: center;
  display: flex; flex-direction: column; gap: 14px;
  animation: cardIn .4s cubic-bezier(.2,.9,.3,1.2) both;
}
.modal-title { font-size: 17px; font-weight: 800; letter-spacing: .15em; color: var(--gold); }
#share-canvas { width: 100%; border-radius: 14px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.modal-actions .btn-main, .modal-actions .btn-ghost { width: 100%; height: 48px; font-size: 16px; }

/* 彩蛋 */
.easter {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.8);
  z-index: 40; max-width: 80vw; text-align: center;
  background: linear-gradient(135deg, rgba(245,195,75,.16), rgba(255,122,194,.14));
  border: 1px solid rgba(245,195,75,.5); border-radius: 24px;
  padding: 26px 28px; color: var(--text); font-size: 17px; font-weight: 600; line-height: 1.8;
  box-shadow: 0 20px 70px rgba(245,195,75,.25); opacity: 0; pointer-events: none;
  transition: opacity .35s ease, transform .35s cubic-bezier(.2,.9,.3,1.3);
}
.easter.pop { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ===== 运势环 ===== */
.score-ring {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin: 8px 0 4px; animation: leadIn .5s ease both;
}
.ring-svg { width: 88px; height: 88px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.08); stroke-width: 8; }
.ring-fg {
  fill: none; stroke: var(--gold); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 327; stroke-dashoffset: 327;
  transition: stroke-dashoffset 1s ease, stroke .3s ease;
}
.ring-text { display: flex; flex-direction: column; align-items: flex-start; }
.ring-num { font-size: 32px; font-weight: 900; color: var(--gold); line-height: 1; }
.ring-label { font-size: 14px; color: var(--dim); margin-top: 4px; }

/* ===== 玩法互跳 ===== */
.game-switcher {
  margin-top: 18px; padding: 14px 16px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--card);
}
.gs-title { font-size: 13px; color: var(--dim); letter-spacing: .08em; margin-bottom: 10px; }
.gs-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.gs-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent;
  color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer;
  transition: transform .15s ease, background .2s ease;
}
.gs-btn:active { transform: scale(.95); }
.gs-btn.current { background: linear-gradient(120deg, var(--gold), var(--pink)); color: var(--dark); border-color: transparent; }
.gs-icon { font-size: 16px; }

/* ===== 桌面适配（≥900px）===== */
@media (min-width: 900px) {
  .app { max-width: 480px; margin: 0 auto; box-shadow: 0 0 80px rgba(0,0,0,.6); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .btn-main:hover { transform: translateY(-2px); }
  .card:hover { background: rgba(255,255,255,.09); }
  .pick-card { animation-delay: 0s !important; }
}
@media (min-width: 900px) and (min-height: 700px) {
  body { display: flex; align-items: center; justify-content: center; }
}