:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --ink: #202124;
  --muted: #697077;
  --line: #d8ddd7;
  --paper: #faf7ef;
  --red: #a9312a;
  --green: #28635a;
  --gold: #b8832d;
  --white: #fffdf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

a {
  color: inherit;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 56px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  color: var(--red);
}

.shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.hero {
  min-height: 280px;
  padding: 32px 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(169, 49, 42, 0.08), rgba(40, 99, 90, 0.08)),
    var(--white);
  display: grid;
  align-content: center;
  gap: 14px;
}

.hero h1,
.panel h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.hero h1 {
  font-size: clamp(36px, 8vw, 72px);
  color: var(--red);
}

.hero p,
.muted {
  color: var(--muted);
  line-height: 1.75;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--white);
  padding: 18px;
}

.panel h2 {
  font-size: 18px;
  margin-bottom: 10px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: 0;
}

button,
select,
input {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
}

button {
  cursor: pointer;
  background: var(--green);
  color: white;
  border-color: var(--green);
  font-weight: 700;
}

button.secondary {
  background: var(--white);
  color: var(--green);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ticket {
  border: 2px solid var(--red);
  background: #fffaf0;
  padding: 22px;
}

.ticket-number {
  font-size: 44px;
  font-weight: 900;
  color: var(--red);
}

.fortune-no {
  color: var(--gold);
  font-weight: 800;
}

.analysis {
  display: grid;
  gap: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  padding: 0 10px;
  background: #fff;
  color: var(--green);
  font-weight: 700;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-weight: 700;
}

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

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .shell {
    padding-inline: 12px;
  }

  .ticket-number {
    font-size: 36px;
  }
}

/* Mobile web interpretation experience */
.interpretation-page {
  --hy-forest: #173f32;
  --hy-forest-deep: #102e25;
  --hy-cinnabar: #b7372d;
  --hy-gold: #b58a42;
  --hy-paper: #f7f3e9;
  --hy-paper-light: #fffdf7;
  --hy-ink: #242a27;
  --hy-muted: #6f756f;
  min-height: 100vh;
  background: var(--hy-paper);
  color: var(--hy-ink);
}

.interpretation-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 58px;
  padding: 10px max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 63, 50, 0.16);
  background: rgba(247, 243, 233, 0.96);
  backdrop-filter: blur(12px);
}

.interpretation-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--hy-forest);
  text-decoration: none;
  font-family: "STSong", "SimSun", serif;
  font-size: 21px;
  font-weight: 700;
}

.brand-seal {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--hy-cinnabar);
  background: var(--hy-cinnabar);
  color: #fff8e8;
  font-size: 17px;
}

.header-label {
  color: var(--hy-muted);
  font-size: 13px;
}

.interpretation-shell,
.scan-home {
  width: min(620px, 100%);
  margin: 0 auto;
  padding: 22px 16px calc(42px + env(safe-area-inset-bottom));
}

.verified-line {
  margin-bottom: 12px;
  color: var(--hy-forest);
  font-size: 13px;
  text-align: center;
}

.verified-line span {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--hy-forest);
  color: white;
  font-size: 11px;
}

.result-ticket {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  padding: 24px 24px 30px;
  border: 1px solid rgba(181, 138, 66, 0.62);
  border-top: 5px solid var(--hy-forest);
  background: var(--hy-paper-light);
  text-align: center;
  box-shadow: 0 14px 34px rgba(28, 45, 37, 0.08);
}

.result-ticket::before,
.result-ticket::after {
  content: "";
  position: absolute;
  width: 52px;
  height: 52px;
  border-color: rgba(181, 138, 66, 0.5);
}

.result-ticket::before {
  top: 12px;
  left: 12px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.result-ticket::after {
  right: 12px;
  bottom: 12px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.ticket-topline {
  display: flex;
  justify-content: space-between;
  color: var(--hy-gold);
  font-size: 13px;
  font-weight: 700;
}

.result-number {
  margin-top: 36px;
  color: var(--hy-cinnabar);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(48px, 15vw, 72px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
}

.result-number em {
  margin: 0 8px;
  color: var(--hy-gold);
  font-style: normal;
  font-weight: 400;
}

.number-label {
  margin: 10px 0 24px;
  color: var(--hy-muted);
  font-size: 12px;
}

.ticket-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--hy-gold);
  font-family: "STSong", "SimSun", serif;
  font-size: 12px;
}

.ticket-divider::before,
.ticket-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(181, 138, 66, 0.35);
}

.result-ticket h1 {
  margin: 22px 0 12px;
  color: var(--hy-forest-deep);
  font-family: "STSong", "SimSun", serif;
  font-size: 30px;
  letter-spacing: 0;
}

.ticket-verse {
  margin: 0 auto;
  max-width: 380px;
  color: #4e5651;
  line-height: 1.85;
}

.hexagram-pair {
  display: grid;
  grid-template-columns: minmax(94px, 1fr) 64px minmax(94px, 1fr);
  align-items: center;
  gap: 6px;
  margin-top: 26px;
  padding-top: 24px;
  border-top: 1px solid rgba(181, 138, 66, 0.35);
}

.hexagram-figure {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.hexagram-figure strong {
  color: var(--hy-forest-deep);
  font-family: "STSong", "SimSun", serif;
  font-size: 17px;
}

.hexagram-figure > span {
  color: var(--hy-muted);
  font-size: 10px;
}

.gua-lines {
  width: 76px;
  display: grid;
  gap: 5px;
}

.gua-line {
  position: relative;
  height: 7px;
  display: flex;
  justify-content: space-between;
}

.gua-line i {
  display: block;
  height: 7px;
  background: var(--hy-forest-deep);
}

.gua-line.is-yang i {
  width: 100%;
}

.gua-line.is-yin i {
  width: 43%;
}

.gua-line.is-moving i {
  background: var(--hy-cinnabar);
}

.gua-line b {
  position: absolute;
  right: -25px;
  top: -5px;
  color: var(--hy-cinnabar);
  font-size: 9px;
}

.change-arrow {
  display: grid;
  justify-items: center;
  gap: 3px;
  color: var(--hy-cinnabar);
}

.change-arrow span {
  font-size: 10px;
}

.change-arrow b {
  font-size: 22px;
  font-weight: 400;
}

.trigram-formula {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 18px;
  color: var(--hy-muted);
  font-size: 11px;
}

.wish-panel,
.reading-panel {
  margin-top: 18px;
  padding: 22px 20px;
  border: 1px solid rgba(23, 63, 50, 0.16);
  background: var(--hy-paper-light);
}

.section-heading h2 {
  margin: 3px 0 0;
  color: var(--hy-forest-deep);
  font-family: "STSong", "SimSun", serif;
  font-size: 23px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--hy-cinnabar);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
}

.section-copy {
  margin: 12px 0 18px;
  color: var(--hy-muted);
  font-size: 13px;
  line-height: 1.7;
}

.interpretation-actions {
  display: grid;
  grid-template-columns: minmax(100px, 0.8fr) minmax(150px, 1.2fr);
  gap: 10px;
}

.interpretation-actions select,
.interpretation-actions button {
  width: 100%;
  min-height: 48px;
  border-radius: 0;
}

.interpretation-actions select {
  border-color: rgba(23, 63, 50, 0.24);
  background: #fff;
  color: var(--hy-forest-deep);
}

.interpretation-actions button {
  border-color: var(--hy-cinnabar);
  background: var(--hy-cinnabar);
}

.reading-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.fire-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--hy-cinnabar);
  color: var(--hy-cinnabar);
  font-family: "STSong", "SimSun", serif;
}

.reading-content {
  margin-top: 20px;
}

.reading-content.is-loading {
  padding: 32px 0;
  color: var(--hy-muted);
  text-align: center;
}

.reading-item {
  padding: 18px 0;
  border-top: 1px solid rgba(23, 63, 50, 0.12);
}

.reading-item h3 {
  margin: 0 0 8px;
  color: var(--hy-cinnabar);
  font-size: 14px;
}

.reading-item p {
  margin: 0;
  color: #424a46;
  font-size: 15px;
  line-height: 1.85;
}

.reading-content blockquote {
  margin: 12px 0 0;
  padding: 20px;
  border-left: 3px solid var(--hy-cinnabar);
  background: #f1ede1;
  color: var(--hy-forest-deep);
  font-family: "STSong", "SimSun", serif;
  font-size: 18px;
  line-height: 1.75;
}

.interpretation-footer {
  padding: 28px 10px 0;
  color: var(--hy-muted);
  font-size: 11px;
  text-align: center;
}

.footer-rule {
  display: block;
  width: 30px;
  height: 2px;
  margin: 0 auto 12px;
  background: var(--hy-cinnabar);
}

.scan-home {
  display: grid;
  min-height: calc(100vh - 58px);
  align-content: center;
  gap: 28px;
}

.scan-intro {
  position: relative;
  padding: 32px 24px;
  border-top: 5px solid var(--hy-forest);
  background: var(--hy-paper-light);
  box-shadow: 0 14px 34px rgba(28, 45, 37, 0.08);
}

.scan-intro h1 {
  margin: 16px 0;
  color: var(--hy-forest-deep);
  font-family: "STSong", "SimSun", serif;
  font-size: 40px;
  line-height: 1.35;
  letter-spacing: 0;
}

.scan-intro > p:last-of-type {
  max-width: 310px;
  color: var(--hy-muted);
  line-height: 1.8;
}

.scan-mark {
  position: relative;
  width: 92px;
  height: 92px;
  margin: 28px auto 4px;
  display: grid;
  place-items: center;
  color: var(--hy-cinnabar);
  font-family: "STSong", "SimSun", serif;
  font-size: 34px;
}

.scan-mark span {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--hy-forest);
}

.scan-mark span:nth-child(1) { top: 0; left: 0; border-top: 3px solid; border-left: 3px solid; }
.scan-mark span:nth-child(2) { top: 0; right: 0; border-top: 3px solid; border-right: 3px solid; }
.scan-mark span:nth-child(3) { bottom: 0; left: 0; border-bottom: 3px solid; border-left: 3px solid; }
.scan-mark span:nth-child(4) { right: 0; bottom: 0; border-right: 3px solid; border-bottom: 3px solid; }

.offline-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(23, 63, 50, 0.18);
  border-bottom: 1px solid rgba(23, 63, 50, 0.18);
}

.offline-steps div {
  padding: 16px 4px;
  display: grid;
  gap: 6px;
  text-align: center;
}

.offline-steps div + div {
  border-left: 1px solid rgba(23, 63, 50, 0.18);
}

.offline-steps strong {
  color: var(--hy-gold);
  font-family: Georgia, serif;
}

.offline-steps span {
  color: var(--hy-forest-deep);
  font-size: 13px;
}

.scan-note {
  margin: 0;
  color: var(--hy-muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

.loading-line {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--hy-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 420px) {
  .interpretation-shell,
  .scan-home {
    padding-inline: 12px;
  }

  .result-ticket {
    padding-inline: 18px;
  }

  .result-number {
    letter-spacing: 1px;
  }

  .result-number em {
    margin-inline: 3px;
  }
}

/* Online draw experience */
.online-home {
  --online-forest: #18372b;
  --online-ink: #17241e;
  --online-paper: #f5f2ea;
  --online-line: #c9cec7;
  min-height: 100vh;
  background: var(--online-paper);
  color: var(--online-ink);
  transition: opacity 240ms ease;
}

.online-home.is-leaving {
  opacity: 0;
}

.online-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 5;
  height: 64px;
  padding: 0 max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fffdf7;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.42);
}

.online-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.online-brand span {
  font-family: "STSong", "SimSun", serif;
  font-size: 24px;
  font-weight: 700;
}

.online-brand small {
  font-size: 11px;
  font-weight: 600;
}

.history-link {
  color: inherit;
  font-size: 13px;
  text-decoration: none;
}

.home-hero {
  position: relative;
  min-height: 66svh;
  max-height: 760px;
  display: grid;
  align-items: end;
  background-color: #375c43;
  background-image: url("/assets/hongyun-meadow.png");
  background-position: center 58%;
  background-size: cover;
}

.home-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(8, 22, 15, 0.18);
  pointer-events: none;
}

.hero-copy {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  margin: 0 auto;
  padding: 120px 24px 48px;
  color: #fffdf7;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.54);
}

.hero-copy > p {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.hero-copy h1 {
  margin: 0;
  font-family: "STSong", "SimSun", serif;
  font-size: 72px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

.hero-copy blockquote {
  margin: 22px 0 0;
  font-family: "STSong", "SimSun", serif;
  font-size: 17px;
  line-height: 1.7;
}

.draw-section {
  padding: 38px 20px 40px;
  border-bottom: 1px solid var(--online-line);
  background: var(--online-paper);
}

.draw-inner,
.recent-inner {
  width: min(620px, 100%);
  margin: 0 auto;
}

.draw-heading p,
.recent-kicker {
  margin: 0 0 7px;
  color: #9a332a;
  font-size: 12px;
  font-weight: 700;
}

.draw-heading h2 {
  margin: 0;
  font-family: "STSong", "SimSun", serif;
  font-size: 27px;
  line-height: 1.45;
  letter-spacing: 0;
}

.draw-form {
  margin-top: 24px;
}

.draw-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.wish-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.wish-options label {
  position: relative;
  min-width: 0;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
}

.wish-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.wish-options label > span {
  width: 100%;
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid #aeb8b0;
  background: #fffdf8;
  color: #405249;
  font-size: 14px;
}

.wish-options input:checked + span {
  border-color: var(--online-forest);
  background: var(--online-forest);
  color: white;
}

.wish-options input:focus-visible + span {
  outline: 3px solid rgba(154, 51, 42, 0.3);
  outline-offset: 2px;
}

.draw-button {
  width: 100%;
  min-height: 54px;
  margin-top: 14px;
  border-color: #9a332a;
  background: #9a332a;
  font-size: 16px;
}

.draw-status {
  min-height: 22px;
  margin: 10px 0 0;
  color: #68746d;
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

.recent-section {
  padding: 26px 20px;
  background: #e8ece6;
}

.recent-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.recent-inner strong {
  color: var(--online-forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.recent-inner a {
  min-width: 86px;
  min-height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--online-forest);
  color: var(--online-forest);
  font-size: 13px;
  text-decoration: none;
}

.online-footer {
  padding: 24px 20px calc(30px + env(safe-area-inset-bottom));
  color: #758078;
  font-size: 11px;
  text-align: center;
}

.result-actions {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.result-actions button,
.result-actions a {
  min-height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--hy-forest);
  background: transparent;
  color: var(--hy-forest);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.result-actions p {
  grid-column: 1 / -1;
  min-height: 18px;
  margin: 0;
  color: var(--hy-muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 520px) {
  .hero-copy h1 {
    font-size: 58px;
  }

  .hero-copy {
    padding-inline: 20px;
  }

  .draw-section {
    padding-inline: 16px;
  }
}

@media (max-width: 360px) {
  .wish-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .draw-heading h2 {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .online-home {
    transition: none;
  }

  html {
    scroll-behavior: auto;
  }
}
