/* ==========================================================================
   本命石 · 素雅国风样式
   配色：宣纸米白 + 墨色 + 黛青 + 朱砂印章
   ========================================================================== */
:root {
  --paper:   #F3EEE3;   /* 宣纸底 */
  --paper-2: #ECE4D5;   /* 卡片底 */
  --paper-3: #E4DAC7;   /* 选中/描边 */
  --ink:     #2C2A26;   /* 墨（主文字） */
  --ink-2:   #6E695E;   /* 次文字 */
  --dai:     #3C574F;   /* 黛青（主色） */
  --dai-2:   #2C403A;   /* 深黛 */
  --zhu:     #9E4A3D;   /* 朱砂（印章/强调） */
  --gold:    #B0894A;   /* 古金 */
  --line:    #D5CAB6;   /* 淡描边 */

  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, "SimSun", serif;
  --sans:  "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;

  --maxw: 460px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  /* 宣纸纹理：极淡的噪点感 */
  background-image:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,.012) 0, transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(0,0,0,.012) 0, transparent 60%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: var(--maxw);
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 22px env(safe-area-inset-bottom);
  background: var(--paper);
  box-shadow: 0 0 60px rgba(44,64,58,.06);
}

/* 屏切换 */
.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; animation: fadeUp .45s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* 通用：印章式品牌字 */
.seal {
  display: inline-block;
  font-family: var(--serif);
  font-weight: 700;
  color: var(--paper);
  background: var(--zhu);
  letter-spacing: 4px;
  padding: 8px 12px 6px;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  writing-mode: vertical-rl;
  box-shadow: 0 2px 8px rgba(158,74,61,.25);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; }

/* ===== 屏1：邀请码 ===== */
#screen-invite { justify-content: center; align-items: center; text-align: center; gap: 4px; }
#screen-invite .brand-seal { margin-bottom: 26px; }
#screen-invite .title {
  font-family: var(--serif); font-size: 27px; font-weight: 700;
  letter-spacing: 2px; color: var(--dai-2); margin-bottom: 4px;
}
#screen-invite .rule { width: 40px; height: 2px; background: var(--gold); margin: 16px auto 20px; opacity:.7; }
#screen-invite .intro {
  font-size: 14px; color: var(--ink-2); white-space: pre-line;
  line-height: 2; margin-bottom: 38px; max-width: 300px;
}
.code-boxes { display: flex; gap: 12px; justify-content: center; margin-bottom: 14px; }
.code-boxes input {
  width: 52px; height: 62px;
  font-family: var(--serif); font-size: 30px; font-weight: 700;
  text-align: center; color: var(--dai-2);
  background: var(--paper-2);
  border: 1.5px solid var(--line); border-radius: 10px;
  outline: none; transition: border-color .2s, background .2s, transform .1s;
  caret-color: var(--dai);
}
.code-boxes input:focus { border-color: var(--dai); background: #fff; }
.code-boxes.error input { border-color: var(--zhu); background: #FBEDE9; }
.code-boxes.shake { animation: shake .4s ease; }
@keyframes shake {
  10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); }
  30%,50%,70% { transform: translateX(-7px); } 40%,60% { transform: translateX(7px); }
}
.code-hint { font-size: 13px; color: var(--ink-2); margin-top: 8px; min-height: 18px; }
.code-hint.err { color: var(--zhu); }

/* ===== 屏2：答题 ===== */
#screen-quiz { padding-top: 18px; }
.q-top { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.q-back {
  font-family: var(--sans); font-size: 13px; color: var(--ink-2);
  background: none; border: none; cursor: pointer; padding: 6px 2px;
  visibility: hidden;
}
.q-back.show { visibility: visible; }
.q-count { margin-left: auto; font-size: 13px; color: var(--ink-2); font-family: var(--serif); letter-spacing: 1px; }
.q-dots { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 30px; }
.q-dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line); transition: background .3s, transform .3s; display:block;
}
.q-dots i.done { background: var(--dai); }
.q-dots i.cur { background: var(--zhu); transform: scale(1.35); }

.q-body { flex: 1; display: flex; flex-direction: column; }
.q-stem {
  font-family: var(--serif); font-size: 23px; font-weight: 700; line-height: 1.5;
  color: var(--ink); margin: 10px 0 34px; letter-spacing: .5px;
}
.q-opts { display: flex; flex-direction: column; gap: 16px; }
.opt {
  text-align: left; cursor: pointer;
  background: var(--paper-2);
  border: 1.5px solid var(--line); border-radius: 14px;
  padding: 22px 20px; font-size: 16.5px; color: var(--ink);
  font-family: var(--sans); line-height: 1.5;
  transition: border-color .18s, background .18s, transform .12s, box-shadow .18s;
  position: relative;
}
.opt:active { transform: scale(.985); }
.opt .mk {
  font-family: var(--serif); color: var(--dai); font-weight: 700;
  margin-right: 10px; opacity: .55;
}
.opt.sel {
  border-color: var(--dai); background: #fff;
  box-shadow: 0 6px 20px rgba(60,87,79,.14);
}
.opt.sel .mk { opacity: 1; color: var(--zhu); }
.q-foot { text-align: center; font-size: 12px; color: var(--ink-2); padding: 22px 0 14px; opacity:.7; font-family: var(--serif); letter-spacing:2px; }

/* 答题切屏动画 */
.q-anim-out { animation: qOut .14s ease forwards; }
.q-anim-in  { animation: qIn .2s ease both; }
@keyframes qOut { to { opacity: 0; transform: translateX(-18px); } }
@keyframes qIn  { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }

/* ===== 屏3：结果 ===== */
#screen-result { padding: 30px 22px 40px; }
.r-head { text-align: center; }
.r-seal { font-family: var(--serif); color: var(--zhu); letter-spacing: 6px; font-size: 13px; }
.r-stone-img {
  width: 130px; height: 130px; margin: 22px auto 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 26px; font-weight: 700; color: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.18), inset 0 2px 12px rgba(255,255,255,.25);
  position: relative; overflow: hidden;
}
.r-stone-img::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.35);
}
.r-type { font-family: var(--serif); font-size: 24px; font-weight: 700; color: var(--ink); text-align: center; letter-spacing: 1px; }
.r-pct { text-align: center; font-size: 13.5px; color: var(--zhu); margin: 8px 0 26px; letter-spacing: 1px; }
.r-pct b { font-family: var(--serif); }

.r-card {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 18px 16px; margin-bottom: 14px;
}
.r-label { font-family: var(--serif); font-size: 13px; letter-spacing: 3px; margin-bottom: 7px; display: flex; align-items: center; gap: 8px; }
.r-label.pro { color: var(--dai); }
.r-label.con { color: var(--gold); }
.r-label::before { content: ""; width: 14px; height: 2px; background: currentColor; display:inline-block; }
.r-card p { margin: 0; font-size: 15px; color: var(--ink); line-height: 1.75; }

.r-stone-card {
  background: linear-gradient(180deg, var(--dai) 0%, var(--dai-2) 100%);
  color: #F3EEE3; border-radius: 14px; padding: 20px 18px; margin: 18px 0 8px;
}
.r-stone-card .sn { font-family: var(--serif); font-size: 19px; font-weight: 700; letter-spacing: 2px; margin-bottom: 10px; display:block; }
.r-stone-card p { margin: 0; font-size: 14.5px; line-height: 1.85; color: #EDE6D7; }

.r-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.btn {
  font-family: var(--serif); font-size: 16px; letter-spacing: 2px;
  border: none; border-radius: 12px; padding: 15px; cursor: pointer;
  transition: transform .12s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--zhu); color: #fff; box-shadow: 0 6px 18px rgba(158,74,61,.28); }
.btn-ghost { background: none; color: var(--ink-2); border: 1px solid var(--line); font-size: 14px; }
.r-disc { font-size: 11px; color: var(--ink-2); line-height: 1.7; margin-top: 22px; opacity: .75; text-align: center; }

/* ===== 海报（离屏 3:4 竖版） ===== */
#poster-wrap { position: fixed; left: -9999px; top: 0; }
#poster {
  width: 600px; height: 800px; background: var(--paper);
  background-image: radial-gradient(circle at 50% 18%, rgba(60,87,79,.06) 0, transparent 55%);
  padding: 56px 50px; display: flex; flex-direction: column; align-items: center; text-align: center;
  font-family: var(--serif); color: var(--ink); position: relative;
}
#poster .p-seal { writing-mode: vertical-rl; background: var(--zhu); color: var(--paper); padding: 14px 12px; font-size: 24px; letter-spacing: 6px; border-radius: 5px; position: absolute; top: 44px; right: 50px; }
#poster .p-kicker { font-size: 16px; color: var(--zhu); letter-spacing: 8px; margin-top: 12px; }
#poster .p-stone { width: 200px; height: 200px; border-radius: 50%; margin: 46px 0 30px; display:flex; align-items:center; justify-content:center; font-size: 40px; font-weight: 700; color:#fff; box-shadow: 0 14px 40px rgba(0,0,0,.2), inset 0 3px 16px rgba(255,255,255,.25); }
#poster .p-type { font-size: 38px; font-weight: 700; letter-spacing: 2px; }
#poster .p-pct { font-size: 18px; color: var(--zhu); margin: 18px 0 26px; letter-spacing: 2px; }
#poster .p-line { font-size: 21px; line-height: 1.9; color: var(--ink); max-width: 440px; font-weight: 500; }
#poster .p-foot { margin-top: auto; font-size: 16px; color: var(--ink-2); letter-spacing: 4px; }
#poster .p-rule { width: 50px; height: 2px; background: var(--gold); opacity:.6; margin: 0 auto; }

/* 生成的海报图展示 */
#poster-result { position: fixed; inset: 0; background: rgba(20,18,14,.82); z-index: 99;
  display: none; flex-direction: column; align-items: center; justify-content: center; padding: 30px; gap: 18px; }
#poster-result.show { display: flex; }
#poster-result img { max-width: 86%; max-height: 70vh; border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.5); }
#poster-result .tip { color: #F3EEE3; font-size: 14px; font-family: var(--sans); }
#poster-result .close { color: #F3EEE3; font-size: 14px; border: 1px solid rgba(255,255,255,.4); padding: 9px 22px; border-radius: 20px; background: none; font-family: var(--sans); cursor: pointer; }

/* ===== 桌面端：居中卡片化 ===== */
@media (min-width: 540px) {
  body { padding: 28px 0; align-items: center; }
  .app { min-height: auto; border-radius: 18px; overflow: hidden;
    box-shadow: 0 20px 60px rgba(44,64,58,.16); border: 1px solid var(--line);
    min-height: min(760px, calc(100dvh - 56px)); }
}
