:root {
  --ink: #0d1630;
  --ink-deep: #080f24;
  --ink-raise: #17224a;
  --ivory: #f4ecd8;
  --text: #f4ecd8;
  --text-soft: #cfc9e2;
  --purple: #a99bff;
  --purple-dim: #5d4fc0;
  --line: rgba(169, 155, 255, 0.35);
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(60rem 30rem at 50% -10%, rgba(111, 91, 214, 0.28), transparent 70%),
    linear-gradient(var(--ink), var(--ink-deep));
  background-color: var(--ink);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  font-size: 17px;
  line-height: 1.7;
}

h1,
h2,
p,
ul,
fieldset {
  margin: 0;
  padding: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
  border-radius: 6px;
}

h1:focus {
  outline: none;
}

/* ---------- 页头 ---------- */
.site-header {
  padding: max(18px, env(safe-area-inset-top)) 16px 0;
  text-align: center;
}

.brand {
  font-size: 13px;
  letter-spacing: 0.24em;
  color: var(--purple);
}

.brand-zh {
  letter-spacing: 0.3em;
}

/* ---------- 布局 ---------- */
.app {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 20px 16px max(40px, env(safe-area-inset-bottom));
}

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view h1 {
  font-family: 'Songti SC', 'Noto Serif SC', 'STSong', serif;
  font-size: 30px;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-wrap: balance;
}

.lead {
  color: var(--text-soft);
}

.notice {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(169, 155, 255, 0.1);
  font-size: 15px;
}

.fineprint {
  font-size: 14px;
  color: var(--text-soft);
  text-align: center;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 10px 20px;
  border: 1.5px solid var(--purple);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: rgba(169, 155, 255, 0.14);
}

.btn.primary {
  border-color: var(--ivory);
  background: var(--ivory);
  color: #16224a;
}

.btn.primary:hover {
  background: #fff8e6;
}

.btn.ghost {
  border-color: transparent;
  color: var(--text-soft);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn[hidden] {
  display: none;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- 牌 ---------- */
.card {
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: 6.5% / 4.3%;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.45));
}

.card svg,
.face svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* 首页牌堆 */
.deck {
  position: relative;
  width: 168px;
  height: 252px;
  margin: 14px auto 6px;
}

.deck .card {
  position: absolute;
  inset: 0;
  transform-origin: 50% 90%;
}

.deck .card:nth-child(1) {
  transform: rotate(-11deg) translateX(-14px);
}

.deck .card:nth-child(2) {
  transform: rotate(9deg) translateX(14px);
}

.home {
  text-align: center;
}

.home form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 主题选择 */
.themes {
  border: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.themes legend {
  width: 100%;
  margin-bottom: 8px;
  font-size: 15px;
  color: var(--text-soft);
}

.theme {
  position: relative;
  display: block;
  cursor: pointer;
}

.theme input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.theme-face {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  padding: 10px 6px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 34, 74, 0.6);
}

.theme-seal {
  display: block;
  width: 56px;
  height: 56px;
  margin: 2px auto 4px;
}

.theme-name {
  font-size: 18px;
  font-weight: 700;
}

.theme-hint {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-soft);
}

.theme input:checked + .theme-face {
  border-color: var(--ivory);
  background: var(--ivory);
  color: #16224a;
}

.theme input:checked + .theme-face .theme-hint {
  color: #3a3f63;
}

.theme input:focus-visible + .theme-face {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

/* 选牌 */
.pick {
  text-align: center;
}

.spread {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 8px 0;
}

.card-btn {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
  transition:
    transform 0.2s ease,
    opacity 0.4s ease;
  -webkit-tap-highlight-color: transparent;
}

.card-btn:hover,
.card-btn:focus-visible {
  transform: translateY(-6px);
}

.card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.3, 0.7, 0.2, 1);
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.45));
}

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.face.front {
  transform: rotateY(180deg);
}

.card-btn.is-flipped {
  transform: translateY(-6px) scale(1.04);
  cursor: default;
}

.card-btn.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.card-btn.is-dimmed {
  opacity: 0.25;
  cursor: default;
  transform: none;
}

/* 结果 */
.result-card .card {
  width: min(64vw, 260px);
  margin: 0 auto;
}

.result.arrive .result-card,
.result.arrive .result-body {
  animation: arrive 0.45s ease both;
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.result-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.eyebrow {
  font-size: 14px;
  letter-spacing: 0.16em;
  color: var(--purple);
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.keywords li {
  padding: 2px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  color: var(--text);
}

.block h2 {
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--purple);
}

.reading {
  font-size: 18px;
}

.step {
  padding: 12px 14px;
  border-left: 3px solid var(--purple);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: rgba(169, 155, 255, 0.1);
}

.feedback:empty {
  display: none;
}

.feedback {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 15px;
}

.feedback label {
  color: var(--text-soft);
}

.invite-kit {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 34, 74, 0.6);
}

.invite-kit img {
  flex: none;
  width: 84px;
  height: auto;
  border-radius: 6px;
}

.invite-kit div {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.copy-field {
  width: 100%;
  min-height: 76px;
  padding: 10px 12px;
  border: 1.5px solid var(--purple);
  border-radius: 10px;
  background: var(--ink-deep);
  color: var(--text);
  font: 15px/1.5 ui-monospace, 'SF Mono', Menlo, monospace;
  resize: none;
  word-break: break-all;
}

/* ---------- 分享卡弹窗 ---------- */
.dialog {
  width: min(92vw, 420px);
  max-height: 92dvh;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--ink-raise);
  color: var(--text);
  overflow: auto;
}

.dialog::backdrop {
  background: rgba(4, 8, 20, 0.78);
}

.dialog h2 {
  font-size: 20px;
}

.dialog-note {
  margin: 4px 0 14px;
  font-size: 14px;
  color: var(--text-soft);
}

.share-preview {
  display: grid;
  place-items: center;
  min-height: 200px;
  margin-bottom: 16px;
  color: var(--text-soft);
}

.share-preview img {
  display: block;
  width: 100%;
  max-width: 300px;
  height: auto;
  border-radius: 10px;
}

/* ---------- 桌面：结果页左牌面右解读 ---------- */
@media (min-width: 900px) {
  .app:has(.result) {
    max-width: 980px;
    padding-top: 48px;
  }

  .result {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 64px;
    align-items: start;
  }

  .result-card .card {
    width: 100%;
  }

  .result-body {
    gap: 18px;
  }

  .view.result h1 {
    font-size: 40px;
  }

  .result .actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .result .fineprint {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ================= 社交玩法 ================= */
a.brand {
  display: inline-block;
  padding: 6px 4px;
  text-decoration: none;
}

.view a:not(.btn):not(.entry) {
  color: var(--purple);
  text-underline-offset: 3px;
}

.hint {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-soft);
}

.error {
  color: #ffb4a8;
  font-size: 15px;
}

.error:empty {
  display: none;
}

.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: progress;
}

/* 纹章（设计稿自带深色圆底与角色主色描边） */
.emblem {
  display: inline-block;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35);
}

.emblem.big {
  width: 128px;
  height: 128px;
}

.emblem svg {
  display: block;
  width: 100%;
  height: 100%;
}

.emblem-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 6px 0;
}

/* 首页 */
.hub {
  text-align: center;
}

.entries {
  display: grid;
  gap: 10px;
  text-align: left;
}

.entry {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 34, 74, 0.6);
  color: var(--text);
  text-decoration: none;
}

.entry:hover {
  border-color: var(--purple);
}

.entry-name {
  font-size: 18px;
  font-weight: 700;
}

.entry-name::after {
  content: ' →';
  color: var(--purple);
}

.entry-hint {
  font-size: 14px;
  color: var(--text-soft);
}

/* 答题 */
.quiz form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-weight: 600;
}

.field input[type='text'] {
  min-height: 48px;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--ink-deep);
  color: var(--text);
  font: inherit;
}

.question {
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question legend {
  margin-bottom: 10px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.45;
}

.q-index {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--purple);
}

.choice {
  position: relative;
  display: block;
  cursor: pointer;
}

.choice input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice-face {
  display: block;
  min-height: 50px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 34, 74, 0.6);
}

.choice input:checked + .choice-face {
  border-color: var(--ivory);
  background: var(--ivory);
  color: #16224a;
  font-weight: 600;
}

.choice input:focus-visible + .choice-face {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

/* 身份卡 */
.id-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 16px 20px;
  border-radius: 20px;
  background: var(--ivory);
  color: #16224a;
  text-align: center;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.4);
}

.id-card .emblem {
  box-shadow: 0 6px 14px rgba(22, 34, 74, 0.3);
  margin-bottom: 6px;
}

.id-owner {
  font-size: 14px;
  letter-spacing: 0.12em;
  color: #4f3fb5;
}

.id-role {
  font-family: 'Songti SC', 'Noto Serif SC', 'STSong', serif;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.id-trait {
  color: #4f3fb5;
}

.tones .theme-face {
  padding: 8px 6px;
  text-align: center;
}

.share-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(23, 34, 74, 0.55);
}

.panel-title {
  font-size: 20px;
}

.card-preview {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  background: var(--ink-deep);
  color: var(--text-soft);
  font-size: 14px;
}

/* 双人关系卡 */
.pair-sides {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 8px;
}

.pair-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.pair-label {
  margin-top: 6px;
  padding: 0 14px;
  border: 1.5px solid var(--purple);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--purple);
}

.pair-role {
  font-family: 'Songti SC', 'Noto Serif SC', 'STSong', serif;
  font-size: 20px;
  font-weight: 700;
}

.pair-x {
  margin-top: 16px;
  font-size: 24px;
  color: var(--purple);
}

/* 每日一签 */
.sign {
  display: flex;
  align-items: center;
  gap: 18px;
}

.sign-list {
  flex: 1;
  margin: 0;
  display: grid;
  gap: 10px;
}

.sign-list div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.sign-list dt {
  flex: none;
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--purple);
  border-radius: 50%;
  text-align: center;
  line-height: 31px;
  font-weight: 700;
  color: var(--purple);
}

.sign-list dd {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

@media (min-width: 900px) {
  .app:has(.me),
  .app:has(.pair),
  .app:has(.friend) {
    max-width: 560px;
  }
}

/* ================= 夜色铜版画：插画 ================= */
.emblem-row {
  display: grid;
  grid-template-columns: repeat(4, 64px);
  justify-content: center;
  gap: 12px;
}

.emblem-row .emblem {
  width: 64px;
  height: 64px;
}

/* 身份卡：插画在上，纹章小头像与职业名在下 */
figure.id-card {
  margin: 0;
  padding: 12px 12px 16px;
  align-items: stretch;
  gap: 14px;
}

.id-art {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1.5px solid #16224a;
}

.id-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 4px;
  text-align: left;
}

.id-card .id-head .emblem {
  flex: none;
  width: 64px;
  height: 64px;
  margin: 0;
}

.id-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.id-text .id-role {
  font-size: 30px;
}

/* 纸色衬边里的插画（塔罗牌面、签画）：保留原始比例，不裁切 */
.plate {
  margin: 0 auto;
  padding: 10px 10px 8px;
  width: fit-content;
  max-width: 100%;
  border-radius: 16px;
  background: var(--ivory);
  color: #16224a;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.45);
}

.plate img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(74vh, 640px);
  margin: 0 auto;
  border-radius: 10px;
  border: 1.5px solid #16224a;
}

.plate figcaption {
  padding-top: 6px;
  text-align: center;
  font-family: 'Songti SC', 'Noto Serif SC', 'STSong', serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.plate-no {
  margin-right: 10px;
  font-size: 16px;
  font-weight: 400;
  color: #4f3fb5;
}

.sign-plate {
  padding-bottom: 10px;
}

/* 翻牌时的牌面：插画按比例放进 2:3 的牌里，四周留纸色 */
.flip-plate {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 5%;
  border-radius: 6.5% / 4.3%;
  background: var(--ivory);
  border: 2px solid #16224a;
}

.flip-plate img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
}

.daily .sign-list {
  grid-template-columns: 1fr 1fr;
}

.sign-full {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sign-full[hidden] {
  display: none;
}

.sign-full:focus {
  outline: none;
}

.btn[hidden] {
  display: none;
}

@media (min-width: 900px) {
  .app:has(.daily) {
    max-width: 560px;
  }
}

/* 上下滚动时不显示滚动条（仍可正常滚动） */
html,
body,
.dialog {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.dialog::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* 顶部的「返回首页」：首页以外的每个页面都有 */
.back-row {
  width: 100%;
  max-width: 460px;
  min-height: 0;
  margin: 0 auto;
  padding: 0 16px;
  text-align: left;
}

.back-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-top: 4px;
  padding: 0 14px 0 8px;
  border-radius: 999px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.back-home span {
  font-size: 22px;
  line-height: 1;
  color: var(--purple);
}

.back-home:hover {
  background: rgba(169, 155, 255, 0.14);
}

.back-home[hidden] {
  display: none;
}

.site-header {
  padding-left: 0;
  padding-right: 0;
}

/* 符文 / 诗签：分享卡预览与下面的保存、发送按钮居中排列 */
#oracle-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#oracle-preview:empty {
  display: none;
}

#oracle-preview img {
  border-radius: 12px;
}

#oracle-preview .btn {
  width: 100%;
  max-width: 480px;
}

/* 符文 / 诗签：生成、复制等提示文字居中 */
#oracle-feedback {
  text-align: center;
}

#oracle-feedback:empty {
  display: none;
}

/* 身份卡里的双人关系卡入口 */
.pair-entry {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1.5px solid var(--purple);
  border-radius: 18px;
  background: rgba(169, 155, 255, 0.12);
}

/* ---------- 塔罗：抽法选择与三张牌阵 ---------- */
.spreads {
  grid-template-columns: repeat(2, 1fr);
}

.spread-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.slot-name {
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--purple);
}

.card-btn[aria-disabled='true'].is-flipped {
  cursor: default;
}

/* 三张牌阵里翻开的牌不需要放大抬起，三张保持齐平 */
.spread-slot .card-btn.is-flipped {
  transform: none;
}

.spread-result {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.spread-cards {
  display: grid;
  gap: 28px;
}

.spread-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.spread-pos {
  font-family: 'Songti SC', 'Noto Serif SC', 'STSong', serif;
  font-size: 24px;
  letter-spacing: 0.06em;
}

.spread-card .plate img {
  max-height: min(60vh, 460px);
}

@media (min-width: 900px) {
  .app:has(.spread-result) {
    max-width: 1100px;
  }

  .result.spread-result {
    display: flex;
  }

  .spread-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  .spread-result .result-body {
    max-width: 640px;
  }
}

/* 三张牌阵标题：三个牌名各自不拆行 */
.view h1.spread-title {
  font-size: 26px;
}

.spread-title span {
  white-space: nowrap;
}

/* 微信内置浏览器：长按图片保存或转发的提示 */
.wechat-hint {
  text-align: center;
}
