/* =========================================================
   陈奕迅演唱会抽签模拟器 · 样式
   移动端优先，纯 CSS，无外部字体与图片依赖
   ========================================================= */

:root {
  --paper: #FFFFFF;
  --paper-2: #FFFFFF;
  --card: #FFFFFF;
  --ink: #1D1D1F;
  --ink-2: #6E6E73;
  --ink-3: #8E8E93;
  --red: #D70015;
  --red-dark: #B00012;
  --line: #E5E5E7;
  --line-strong: #D2D2D7;
  --fill: #F5F5F7;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background: #FFFFFF;
  overscroll-behavior-y: none;
}

#app { max-width: 480px; margin: 0 auto; position: relative; }

/* ---------- 屏幕切换 ---------- */
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.is-active { display: block; }
.screen.is-active > .wrap { animation: screenIn .34s cubic-bezier(.22, .8, .3, 1) both; }
.screen[data-screen="transition"].is-active .transition-box { animation: screenIn .34s cubic-bezier(.22, .8, .3, 1) both; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.wrap { padding: 0 20px calc(28px + var(--safe-b)); }
.wrap--home { padding-top: 40px; display: flex; flex-direction: column; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 0 22px;
  height: 54px;
  cursor: pointer;
  transition: transform .12s ease, opacity .2s ease, background .2s ease;
  touch-action: manipulation;
  user-select: none;
}
.btn:active { transform: scale(.975); }
.btn--block { width: 100%; }
.btn--primary {
  background: var(--ink);
  color: #FFFFFF;
  box-shadow: none;
}
.btn--primary:disabled {
  background: var(--fill);
  color: #C7C7CC;
  box-shadow: none;
  cursor: not-allowed;
}
.btn--ghost {
  background: #FFFFFF;
  border-color: var(--line-strong);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  height: 48px;
}
.btn--link {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 500;
  height: 40px;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.micro {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: .02em;
}

/* ---------- 首页 ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink-2);
}
.badge--line {
  background: transparent;
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.home-title {
  margin: 22px 0 0;
  font-size: clamp(34px, 9.6vw, 42px);
  line-height: 1.22;
  font-weight: 800;
  letter-spacing: -.02em;
}
.home-title em {
  font-style: normal;
  color: var(--red);
  position: relative;
  display: inline-block;
  z-index: 0;
}
.home-title em::after {
  content: "";
  position: absolute;
  left: 2px; right: 2px; bottom: 2px;
  height: 8px;
  background: rgba(196, 55, 46, .14);
  border-radius: 4px;
  z-index: -1;
}

.home-sub {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  letter-spacing: .01em;
}
.home-meta {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: .02em;
}
.home-intro {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-2);
}

.home-art {
  margin: 22px auto 0;
  width: min(62vw, 230px);
  aspect-ratio: 1;
  transform: rotate(-2deg);
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .08));
}
.home-art svg { width: 100%; height: 100%; display: block; border-radius: 22px; }

.howto {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  gap: 9px;
}
.howto li {
  font-size: 13.5px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.howto b {
  flex: none;
  width: 21px; height: 21px;
  border-radius: 50%;
  border: 1.4px solid var(--line-strong);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  color: var(--ink-2);
}

.home-cta { margin-top: 26px; }

.disclaimer {
  margin: 22px 0 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-3);
  text-align: center;
}
.disclaimer b { color: var(--ink-2); font-weight: 600; }

.statsline {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .02em;
}

/* 12 小时锁定卡 */
.lockcard {
  margin-top: 20px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: inset 0 0 0 1.5px var(--line);
  text-align: center;
}
.lockcard[hidden] { display: none; }
.lockcard__k { margin: 0; font-size: 13px; color: var(--ink-3); }
.lockcard__v { margin: 6px 0 0; font-size: 17px; font-weight: 700; }
.lockcard__t { margin: 8px 0 16px; font-size: 13px; color: var(--ink-2); }
.lockcard__t b { font-variant-numeric: tabular-nums; color: var(--red-dark); }

/* ---------- 选专辑 ---------- */
.wrap--select { padding-top: 14px; padding-bottom: 160px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
}
.iconbtn {
  width: 40px; height: 40px;
  margin-left: -8px;
  border: none;
  background: none;
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.iconbtn:active { background: rgba(27, 25, 23, .06); }
.counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--fill);
  box-shadow: none;
}

.select-head { margin: 6px 0 20px; }
.select-head h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.35;
  font-weight: 800;
  letter-spacing: -.01em;
}
.select-head p { margin: 8px 0 0; font-size: 13px; color: var(--ink-3); }

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.acard {
  position: relative;
  display: flex;
  flex-direction: column;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 7px 7px 9px;
  cursor: pointer;
  font-family: var(--font);
  color: var(--ink);
  transition: border-color .16s ease, transform .14s ease, box-shadow .16s ease;
  animation: cardIn .4s cubic-bezier(.22, .8, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 18ms);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.acard:active { transform: scale(.98); }
.acard.is-on {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(215, 0, 21, .14);
}
.acard.is-locked { opacity: .45; }

.acard__art {
  position: relative;
  flex: none;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--fill);
}
.acard__art svg { display: block; width: 100%; height: 100%; }

/* 封面：单张 / 双拼 / 三拼（同一个正方形区域内） */
.cover { display: block; width: 100%; height: 100%; object-fit: cover; }
.art-grid { display: grid; width: 100%; height: 100%; gap: 2px; background: #FFFFFF; }
.art-grid--2 { grid-template-columns: 1fr 1fr; }
.art-grid--3 { grid-template-columns: 1.62fr 1fr; }
.art-col { display: grid; grid-template-rows: 1fr 1fr; gap: 2px; min-height: 0; }
.art-grid .cover, .art-col .cover { min-width: 0; min-height: 0; }
.acard__count {
  position: absolute;
  top: 5px; right: 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink-2);
  background: rgba(255, 255, 255, .94);
  padding: 1px 5px;
  border-radius: 999px;
}

.acard__no {
  position: absolute;
  top: 5px; left: 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-2);
  background: rgba(255, 255, 255, .78);
  padding: 1px 5px;
  border-radius: 999px;
}
.acard__check {
  position: absolute;
  right: 5px; bottom: 5px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: none;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(215, 0, 21, .35);
}
.acard.is-on .acard__check { display: grid; }

.acard__name {
  flex: 1 1 auto;
  margin: 7px 1px 0;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.005em;
  word-break: break-word;
  min-height: 2.6em;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.acard__sub {
  display: block;
  margin-top: 1px;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-3);
  line-height: 1.3;
}
.acard__date {
  margin: 5px 1px 0;
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.acard__date b { font-weight: 700; }

.sourcenote {
  margin: 20px 2px 0;
  font-size: 11px;
  line-height: 1.65;
  color: var(--ink-3);
}

.actionbar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 20px calc(12px + var(--safe-b));
  background: linear-gradient(to top, #FFFFFF 62%, rgba(255, 255, 255, 0));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  z-index: 20;
}
.screen[data-screen="select"].is-active .actionbar { display: block; }
.actionbar .micro { margin-top: 8px; }

/* ---------- 过渡 ---------- */
.screen[data-screen="transition"] {
  background: var(--paper);
}
.transition-box {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 28px;
  text-align: center;
}
.reel {
  display: flex;
  gap: 7px;
  margin-bottom: 26px;
}
.reel span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink);
  opacity: .22;
  animation: dot 1.1s ease-in-out infinite;
}
.reel span:nth-child(2) { animation-delay: .16s; }
.reel span:nth-child(3) { animation-delay: .32s; }
@keyframes dot {
  0%, 100% { opacity: .2; transform: scale(.82); }
  45%      { opacity: 1; transform: scale(1); }
}
.t-step {
  margin: 0;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -.01em;
  animation: stepIn .45s ease both;
}
@keyframes stepIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.t-sub {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--ink-3);
  min-height: 1.4em;
}
.t-bar {
  margin-top: 34px;
  width: min(62vw, 220px);
  height: 3px;
  border-radius: 999px;
  background: var(--fill);
  overflow: hidden;
}
.t-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--red);
  border-radius: 999px;
  transition: width .3s linear;
}

/* ---------- 结果 ---------- */
.wrap--result {
  padding-top: 18px;
  padding-bottom: calc(26px + var(--safe-b));
}
.card-holder {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px -22px rgba(0, 0, 0, .45);
  background: #FFFFFF;
  animation: cardPop .5s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes cardPop {
  from { opacity: 0; transform: translateY(16px) scale(.975); }
  to   { opacity: 1; transform: none; }
}
#resultCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
}

.result-actions { margin-top: 18px; display: grid; gap: 10px; }
.result-actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-actions .row--single { grid-template-columns: 1fr; }
.result-note {
  margin: 16px 0 0;
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-3);
  text-align: center;
}

/* ---------- 大图层 ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(18, 16, 14, .94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 16px;
  animation: fade .22s ease both;
}
.sheet[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet__inner {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.sheet__tip {
  margin: 0;
  color: rgba(255, 250, 240, .82);
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}
.sheet img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 12px;
  background: #FAF4E8;
}
.sheet__actions { display: flex; gap: 10px; width: 100%; }
.sheet__actions .btn { flex: 1; height: 48px; font-size: 15px; }
.sheet__actions .btn--ghost { color: #fff; border-color: rgba(255, 255, 255, .38); }

/* ---------- 专辑详情面板（选中后出现，默认收起） ---------- */
.screen.is-detail .wrap--select { padding-bottom: 268px; }

.detail {
  position: fixed;
  left: 50%;
  bottom: calc(104px + var(--safe-b));
  width: calc(100% - 24px);
  max-width: 456px;
  z-index: 18;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 12px 32px -20px rgba(0, 0, 0, .35), inset 0 0 0 1px var(--line);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 14px);
  transition: opacity .22s ease, transform .28s cubic-bezier(.22, .8, .3, 1), visibility .22s;
  pointer-events: none;
}
.detail.is-on {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.detail__head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px 10px 10px;
  border: none;
  background: none;
  font-family: var(--font);
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.detail__pix {
  flex: none;
  width: 48px; height: 48px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--fill);
  box-shadow: inset 0 0 0 1px var(--line);
}
.detail__pix svg { display: block; width: 100%; height: 100%; }
.detail__pix img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail__main { flex: 1 1 auto; min-width: 0; display: block; }
.detail__main b {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.32;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail__main em {
  display: block;
  margin-top: 3px;
  font-style: normal;
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.detail__more {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-2);
  padding: 6px 9px 6px 11px;
  border-radius: 999px;
  background: rgba(27, 25, 23, .055);
}
.chev {
  width: 7px; height: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform .26s ease;
}
.detail.is-open .chev { transform: rotate(-135deg) translate(-2px, -2px); }

.detail__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s cubic-bezier(.22, .8, .3, 1);
}
.detail.is-open .detail__body { max-height: 320px; overflow-y: auto; }

.songs { list-style: none; margin: 0; padding: 0 14px; }
.songs li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 12.5px;
  color: var(--ink);
  border-top: 1px solid var(--line);
}
.songs__album {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0 6px !important;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
  border-top: 1px solid var(--line);
}
.songs__album b { flex: 1 1 auto; min-width: 0; font-size: 11.5px; font-weight: 700; line-height: 1.35; }
.songs__thumb {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px var(--line);
}
.songs__album:first-child { border-top: none; }
.songs__album span { font-size: 10px; font-weight: 500; color: var(--ink-3); }
.songs li.songs__src {
  display: block;
  padding: 9px 0 8px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--ink-3);
  border-top: none;
}
.songs li:first-child { border-top: none; }
.songs .idx {
  flex: none;
  width: 15px;
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.detail__note {
  margin: 4px 14px 13px;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--ink-3);
}

/* ---------- 小屏适配 ---------- */
@media (max-width: 360px) {
  .home-title { font-size: 30px; }
  .acard__name { font-size: 12.5px; }
  .btn { font-size: 16px; }
}

@media (min-width: 520px) {
  body { padding: 24px 0; }
  #app {
    border-radius: 28px;
    box-shadow: 0 24px 60px -34px rgba(0, 0, 0, .35), 0 0 0 1px var(--line);
    overflow: hidden;
    background: var(--paper);
  }
  .screen { min-height: 780px; }
  .actionbar { max-width: 480px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(122px + var(--safe-b));
  transform: translate(-50%, 12px);
  z-index: 200;
  max-width: 84vw;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(29, 29, 31, .92);
  color: #FFFFFF;
  font-size: 13.5px;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
