:root {
  color-scheme: light;
  --paper: #fbfaf6;
  --ink: #22211f;
  --muted: #5f5a53;
  --red: #7a633f;
  --line: rgba(34, 33, 31, 0.14);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(circle at 78% 15%, rgba(177, 148, 105, 0.12), transparent 30rem), linear-gradient(180deg, #fffefd, var(--paper) 38rem);
  color: var(--ink);
  font-family: Inter, Avenir, system-ui, -apple-system, "Noto Sans TC", "PingFang TC", sans-serif;
  line-height: 1.75;
}
a {
  color: var(--red);
  text-underline-offset: 5px;
}
a:hover {
  color: #513c20;
}
button,
input,
select {
  font: inherit;
}
button,
.button {
  border: 1px solid var(--red);
  background: var(--red);
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
}
button:hover {
  background: #604c2e;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
input,
select {
  padding: 9px 12px;
  max-width: 100%;
  border: 1px solid #8b8e84;
  background: #fffdf8;
  border-radius: 3px;
  color: var(--ink);
}
:focus-visible {
  outline: 3px solid #386a70;
  outline-offset: 5px;
}
.site-header {
  max-width: 1160px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, .68);
}
.brand {
  font-family: "Songti TC", "Noto Serif TC", serif;
  font-size: 28px;
  font-weight: bold;
  text-decoration: none;
  color: var(--ink);
}
.brand small {
  font: 12px system-ui;
  letter-spacing: 1px;
  margin-left: 12px;
  color: var(--muted);
}
nav {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 14px;
}
nav a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, color .2s ease;
}
nav a:hover, nav a:focus-visible { border-color: currentColor; }
main {
  max-width: 880px;
  margin: auto;
  padding: 64px 28px 80px;
}
main:has(.hero), main:has(.cast-heading) { max-width: 1080px; }
h1,
h2,
h3 {
  font-family: "Songti TC", "Noto Serif TC", serif;
  line-height: 1.45;
}
h1 {
  font-size: clamp(32px, 5vw, 54px);
  font-weight: 600;
  margin: 0 0 24px;
  letter-spacing: -.025em;
}
h2 {
  font-size: 27px;
  margin: 0 0 22px;
}
h3 {
  font-size: 21px;
  margin-top: 32px;
}
p {
  margin: 0 0 20px;
}
section {
  border-top: 1px solid var(--line);
  padding-top: 32px;
  margin-top: 44px;
}
.hero {
  padding: 48px 0 66px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: clamp(32px, 5vw, 76px);
  align-items: center;
}
.hero-copy { min-width: 0; }
.hero-play {
  position: relative;
  padding: 28px 30px 22px;
  background: #f2eee6;
  border: 1px solid var(--line);
  box-shadow: 16px 16px 0 rgba(122, 99, 63, .08);
}
.hero-play::before {
  content: "易";
  position: absolute;
  top: 8px;
  right: 26px;
  color: rgba(122, 99, 63, .13);
  font: 94px/1 "Songti TC", serif;
  pointer-events: none;
}
.hero-play-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--red);
  font-size: 11px;
  letter-spacing: .17em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 22px;
}
.hero-play h2 { position: relative; font-size: clamp(24px, 2.6vw, 30px); margin-bottom: 12px; }
.hero-play .status { position: relative; margin: 0; }
.hero-play .line-controls { max-width: none; margin: 22px 0 16px; gap: 6px; }
.hero-play .line-controls button {
  display: flex;
  align-items: center;
  min-height: 45px;
  padding: 7px 13px;
  border-color: rgba(122, 99, 63, .24);
  background: rgba(255, 254, 251, .65);
  font-variant-numeric: tabular-nums;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.hero-play .line-controls button:hover {
  transform: translateX(5px);
  background: #fffefd;
  border-color: var(--red);
}
.hero-play .line-controls button[aria-pressed="false"] { background: #eae1d2; }
.hero-play .feedback { min-height: 3em; margin-bottom: 0; color: var(--red); font-size: 14px; }
.cast-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .84fr);
  gap: clamp(34px, 5vw, 68px);
  align-items: center;
  margin-bottom: 46px;
}
.cast-heading-copy { min-width: 0; }
.cast-heading .notice { margin-top: 28px; }
.cast-jump { display: inline-block; margin-top: 6px; font-size: 14px; font-weight: 600; }
.editorial-photo { position: relative; margin: 0; min-width: 0; }
.editorial-photo::before {
  content: "";
  position: absolute;
  inset: 14px -14px -14px 14px;
  border: 1px solid rgba(122, 99, 63, .32);
  pointer-events: none;
}
.editorial-photo img {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  filter: saturate(.88);
}
.editorial-photo figcaption {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--red);
}
.feature-scene {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, .75fr);
  gap: clamp(44px, 8vw, 112px);
  align-items: center;
  margin-top: 38px;
  padding: 74px 0 44px;
}
.feature-scene h2 { font-size: clamp(30px, 3.6vw, 43px); }
.feature-scene p:not(.eyebrow) { max-width: 26em; color: var(--muted); }
.feature-scene .editorial-photo { max-width: 360px; justify-self: end; }
#cast-form, #result { max-width: 880px; }
.lead {
  font-size: 19px;
  max-width: 600px;
  color: var(--muted);
}
.eyebrow {
  letter-spacing: 3px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 20px;
}
.actions {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 32px;
}
footer {
  max-width: 1100px;
  margin: auto;
  padding: 32px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.source {
  font-size: 12px;
  color: var(--muted);
  margin-top: 32px;
}
.hexagram {
  width: 110px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 22px 0;
}
.line {
  display: flex;
  height: 8px;
  gap: 13px;
}
.line i {
  background: var(--ink);
  flex: 1;
}
.line.yang {
  gap: 0;
}
.line.moving i {
  background: var(--red);
}
.cast-board {
  display: grid;
  gap: 7px;
  max-width: 510px;
  margin: 24px 0 36px;
  padding: 22px;
  background: #f2eee6;
  border: 1px solid var(--line);
}
.cast-slot {
  display: grid;
  grid-template-columns: 72px 1fr 112px;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid rgba(122, 99, 63, .14);
  color: var(--muted);
  background: rgba(255, 254, 251, .4);
}
.cast-slot small { font-size: 12px; }
.cast-slot em { font-size: 12px; font-style: normal; text-align: right; }
.cast-stroke { color: var(--red); font-size: 20px; font-weight: 700; text-align: center; white-space: nowrap; letter-spacing: .08em; }
.cast-slot.is-filled { background: #fffefd; color: var(--ink); }
.cast-slot.is-new { border-color: var(--red); animation: cast-arrive .35s ease-out; }
@keyframes cast-arrive { from { opacity: .4; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.skip {
  position: absolute;
  left: 12px;
  top: -100px;
  background: white;
  padding: 10px;
}
.skip:focus {
  top: 10px;
}
.entry-list {
  list-style: none;
  padding: 0;
}
.entry-list li {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.entry-list a {
  font-size: 20px;
  text-decoration: none;
}
.entry-list p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 14px;
}
.hex-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0 22px;
  list-style: none;
  padding: 0;
}
.hex-list li {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.hex-list a {
  display: block;
  text-decoration: none;
}
.hex-list small {
  color: var(--muted);
}
.notice {
  background: #f2eee6;
  border-left: 3px solid var(--red);
  padding: 18px 20px;
  font-size: 14px;
}
.feedback {
  min-height: 2em;
  color: #46623e;
  font-weight: 500;
}
.question {
  border: 0;
  padding: 18px 0;
  margin: 20px 0;
}
.question legend {
  font-weight: 600;
}
.question button {
  display: block;
  text-align: left;
  width: 100%;
  margin: 8px 0;
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.question button[aria-pressed="true"] {
  border-color: var(--red);
  background: #eee6d8;
}
.split {
  display: flex;
  gap: 36px;
  flex-wrap: wrap;
}
.stack {
  display: grid;
  gap: 14px;
}
.line-controls {
  display: flex;
  flex-direction: column-reverse;
  gap: 9px;
  margin: 20px 0;
  max-width: 330px;
}
.line-controls button {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  text-align: left;
}
.line-controls .moving {
  color: var(--red);
}
.field {
  display: block;
  margin: 18px 0;
}
.field > span {
  display: block;
  margin-bottom: 6px;
}
details {
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}
summary {
  cursor: pointer;
}
#result:empty {
  display: none;
}
.history-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.quiet {
  background: transparent;
  color: var(--red);
}
.status {
  font-size: 14px;
  color: var(--muted);
}
@media (max-width: 650px) {
  .site-header {
    display: block;
    padding: 20px;
  }
  nav {
    gap: 16px;
    margin-top: 18px;
  }
  .brand small {
    display: inline;
  }
  main {
    padding: 38px 22px 60px;
  }
  .hero {
    padding: 16px 0 38px;
    grid-template-columns: 1fr;
    gap: 34px;
  }
  .hero-play { padding: 22px 22px 16px; box-shadow: 10px 10px 0 rgba(122, 99, 63, .08); }
  .cast-heading, .feature-scene { grid-template-columns: 1fr; gap: 28px; }
  .cast-heading { margin-bottom: 40px; }
  .cast-heading .editorial-photo img { aspect-ratio: 16 / 9; object-position: center 62%; }
  .feature-scene { padding: 38px 0 44px; }
  .feature-scene .editorial-photo { width: min(100%, 390px); justify-self: start; }
  .editorial-photo figcaption { font-size: 10px; }
  .cast-board { padding: 13px; }
  .cast-slot { grid-template-columns: 54px 1fr 94px; gap: 3px; padding: 6px; }
  .cast-slot em, .cast-slot small { font-size: 11px; }
  .cast-stroke { font-size: 16px; letter-spacing: 0; }
  .hex-list {
    grid-template-columns: repeat(2, 1fr);
  }
  footer {
    padding: 24px;
  }
  .actions {
    gap: 20px;
  }
  h1 {
    font-size: 36px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    animation: none !important;
  }
}
