/* 龜卜卜六爻小幫手：星夜書齋 */
:root {
  --night: #070b22;
  --night-2: #0d1434;
  --glass: rgba(12, 18, 46, 0.84);
  --well: rgba(5, 9, 28, 0.55);
  --gold: #d6b46a;
  --gold-bright: #f0d48e;
  --gold-soft: rgba(214, 180, 106, 0.45);
  --gold-faint: rgba(214, 180, 106, 0.18);
  --text: #efe6d2;
  --text-soft: #b9b09c;
  --cinnabar: #b0352a;
  --cinnabar-light: #d0503f;
  --cinnabar-dark: #8e2a21;
  --moving: #f08a7a;
  --page-width: 560px;
  --font-serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", "MingLiU", serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--night);
  background-image:
    radial-gradient(ellipse at 70% 0%, rgba(70, 90, 170, 0.35), transparent 60%),
    radial-gradient(ellipse at 10% 100%, rgba(214, 180, 106, 0.08), transparent 55%),
    linear-gradient(180deg, #0a1030 0%, #070b22 55%, #05071a 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.75;
}

/* 背景星空（js/sky.js 畫在這張畫布上） */
#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.sky-vignette {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(3, 5, 16, 0.65) 100%);
}

.page {
  position: relative;
  z-index: 1;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 頁首 */
.site-header {
  padding: 40px 0 6px;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.site-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #f6ecd6;
  text-shadow: 0 0 18px rgba(214, 180, 106, 0.35);
}

.seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  flex-shrink: 0;
  background: var(--cinnabar);
  color: #fdf6e8;
  border-radius: 6px;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(253, 246, 232, 0.25), 0 4px 14px rgba(0, 0, 0, 0.35);
}

.tagline {
  margin: 10px 0 0;
  font-size: 0.85rem;
  letter-spacing: 0.5em;
  color: var(--gold);
  opacity: 0.9;
}

.header-rule {
  max-width: 320px;
  height: 1px;
  margin: 16px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
}

/* 主內容 */
.site-main {
  flex: 1;
  padding: 20px 0 40px;
}

[hidden] { display: none !important; }

/* 區塊：深藍玻璃＋金色細框＋左上右下角飾 */
.panel,
.summary {
  position: relative;
  border: 1px solid var(--gold-soft);
  border-radius: 12px;
  background: var(--glass);
  box-shadow: 0 0 0 4px rgba(7, 11, 34, 0.6), 0 0 0 5px var(--gold-faint), 0 18px 40px rgba(0, 0, 0, 0.35);
  margin-bottom: 22px;
}

.panel { padding: 22px 20px; }

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--gold);
  pointer-events: none;
}

.panel::before { top: 7px; left: 7px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: 7px; right: 7px; border-left: 0; border-top: 0; }

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.25em;
}

.panel-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--gold-soft), transparent);
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: 1px solid var(--gold-soft);
  border-radius: 50%;
  font-size: 0.78rem;
  letter-spacing: 0;
  line-height: 1;
}

/* 首頁相遇區：主形象圖＋開場白＋閱讀完整故事 */
.encounter {
  margin-bottom: 22px;
  text-align: center;
}

.encounter-img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--gold-soft);
  border-radius: 12px;
  box-shadow: 0 0 0 4px rgba(7, 11, 34, 0.6), 0 0 0 5px var(--gold-faint), 0 18px 40px rgba(0, 0, 0, 0.35);
}

.encounter-lines {
  margin: 18px 0 0;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.9;
  letter-spacing: 0.04em;
}

.encounter-lines p { margin: 0; }

/* 每個短句不拆開，窄螢幕只在逗號後換行 */
.encounter-lines span { display: inline-block; }

.encounter-more { margin: 10px 0 0; }

.encounter-more a {
  color: var(--gold);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.encounter-more a:hover,
.encounter-more a:focus-visible {
  color: var(--gold-bright);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* 新手說明框：點標題展開／收起 */
.guide > summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0;
  padding: 4px 0;
}

.guide > summary::-webkit-details-marker { display: none; }

.guide[open] > summary { margin-bottom: 14px; }

.guide-mark {
  order: 2;
  flex-shrink: 0;
  font-size: 1.2rem;
  letter-spacing: 0;
  transition: transform 0.2s ease;
}

.guide[open] .guide-mark { transform: rotate(180deg); }

.guide-steps {
  margin: 0;
  padding-left: 1.4em;
  color: var(--text);
  line-height: 1.8;
}

.guide-steps li + li { margin-top: 12px; }

.guide-steps li::marker { color: var(--gold); }

.guide-steps p { margin: 0; }

.guide-step-title {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* 表單欄位 */
.field { margin-bottom: 16px; }

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid rgba(214, 180, 106, 0.3);
  border-radius: 8px;
  background: var(--well);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(214, 180, 106, 0.15);
}

.input::placeholder { color: #7f7a6e; }

select.input option { background: var(--night-2); color: var(--text); }

.input-multiline {
  display: block;
  line-height: 1.6;
  resize: vertical;
}

.time-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 窄螢幕放不下時，「填入現在時間」自動換到下一行 */
.time-row .input {
  flex: 1 1 240px;
  min-width: 0;
}

/* 按鈕：次要按鈕金框、主要按鈕朱紅漸層 */
.btn {
  min-height: 48px;
  padding: 8px 16px;
  border: 1px solid var(--gold-soft);
  border-radius: 8px;
  background: transparent;
  color: var(--gold);
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.btn:hover { background: rgba(214, 180, 106, 0.08); border-color: var(--gold); }
.btn:active { background: rgba(214, 180, 106, 0.16); }

.btn:disabled {
  border-color: rgba(214, 180, 106, 0.18);
  color: #6f6a5f;
  background: transparent;
  cursor: not-allowed;
}

.btn-small {
  flex-shrink: 0;
  font-size: 0.9rem;
  padding: 8px 12px;
}

.btn-primary {
  border-color: #d86a59;
  background: linear-gradient(180deg, var(--cinnabar-light), var(--cinnabar));
  color: #fdf6e8;
  font-weight: 700;
  letter-spacing: 0.2em;
  box-shadow: 0 6px 18px rgba(176, 53, 42, 0.35);
}

.btn-primary:hover {
  border-color: #e07a69;
  background: linear-gradient(180deg, var(--cinnabar-light), var(--cinnabar));
  box-shadow: 0 8px 24px rgba(176, 53, 42, 0.5);
}

.btn-primary:active { background: var(--cinnabar-dark); }

.btn-primary:disabled {
  border-color: rgba(214, 180, 106, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: #6f6a5f;
  box-shadow: none;
}

.btn-block {
  display: block;
  width: 100%;
}

/* 摘要列 */
.summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-left: 3px solid var(--cinnabar);
}

.summary-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.summary-tag {
  padding: 0 8px;
  border-radius: 4px;
  background: var(--cinnabar);
  color: #fdf6e8;
  font-size: 0.85rem;
}

.summary-question {
  flex-basis: 100%;
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

/* 擲卦區 */
.throw-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.throw-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 72px;
  padding: 10px 4px;
  border: 1px solid rgba(214, 180, 106, 0.3);
  border-radius: 10px;
  background: var(--well);
  color: var(--text);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.throw-btn:hover { border-color: var(--gold); background: rgba(214, 180, 106, 0.08); }
.throw-btn:active { background: rgba(214, 180, 106, 0.16); }

.coins {
  display: flex;
  gap: 3px;
}

.coin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  font-size: 10px;
  font-weight: 400;
  line-height: 1;
}

.coin-back { background: var(--gold); }

.coin-face { background: transparent; color: var(--gold); }

.coin-note {
  margin: -4px 0 16px;
  color: var(--text-soft);
  font-size: 0.85rem;
  line-height: 1.6;
}

.coin-note p { margin: 0 0 2px; }

.coin-note strong { color: var(--text); }

.coin-note ul {
  margin: 0;
  padding-left: 1.2em;
}

/* 卦象：第一擲在最下面，往上長 */
.hexagram-log {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  margin: 0 0 16px;
  padding: 14px 12px;
  list-style: none;
  border: 1px solid var(--gold-faint);
  border-radius: 8px;
  background: var(--well);
}

.yao-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.yao {
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
  width: 84px;
  height: 12px;
}

.yao i {
  display: block;
  height: 100%;
  background: var(--text);
  border-radius: 1px;
}

.yao-yang i { width: 100%; }

.yao-yin i { width: 42%; }

.yao-mark {
  flex-shrink: 0;
  width: 1.2em;
  text-align: center;
  font-weight: 700;
}

.yao-note {
  flex: 1;
  min-width: 0;
  color: var(--text-soft);
  font-size: 0.85rem;
  line-height: 1.4;
}

.is-moving .yao i { background: var(--cinnabar-light); }

.is-moving .yao-mark,
.is-moving .yao-note { color: var(--moving); }

/* 結果區 */
.result-figures {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
  padding: 16px 8px 18px;
  border: 1px solid var(--gold-faint);
  border-radius: 8px;
  background: var(--well);
}

.figure-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.figure-name {
  margin: 0 0 10px;
  color: var(--gold-bright);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.figure {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 每一行固定高度，本卦與變卦的爻才會一對一對齊 */
.figure-row {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 14px;
}

.figure-row .yao-mark { line-height: 1; }

.yao-lg {
  width: 72px;
  height: 12px;
}

/* 變卦不標 ○ ✕，但留出同樣寬度，兩邊卦象才會對稱 */
.figure-changed .yao-mark { visibility: hidden; }

.figure-arrow {
  font-size: 1.4rem;
  color: var(--gold);
}

/* 卦象牌卡：本卦、變卦並排；變卦只把中間的畫左右翻轉，上下的字與卦畫不翻 */
.hex-cards {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.hex-card-col {
  flex: 0 1 240px;
  min-width: 0;
  margin: 0;
}

.hex-card-col figcaption {
  margin-top: 8px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.8rem;
  letter-spacing: 0.4em;
}

.hex-card {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #1a1d2e;
  aspect-ratio: 683 / 1024;
  cursor: zoom-in;
  box-shadow: 0 0 0 1px var(--gold-soft), 0 10px 26px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s, box-shadow 0.25s;
}

.hex-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 0 1px var(--gold), 0 0 24px rgba(214, 180, 106, 0.35), 0 14px 30px rgba(0, 0, 0, 0.5);
}

.hex-card:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }

.hex-card img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* 插畫區在原圖 y=170～1352、x=22～1002（1024×1536），左右對稱，翻轉後位置不變 */
.hex-card .hex-flip {
  display: none;
  transform: scaleX(-1);
  clip-path: inset(11.07% 2.15% 11.98% 2.15%);
}

.hex-card.is-mirror .hex-flip { display: block; }

.hex-arrow {
  flex: none;
  margin-bottom: 26px;
  color: var(--gold);
  font-size: 1.4rem;
}

.hex-hint {
  margin: 10px 0 18px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.75rem;
}

/* 我的啟發 */
.insight { margin-bottom: 20px; }

/* 至少 3 行高；手機一行字少，打滿 60 字時框跟著長高，不出現捲軸 */
.insight .input {
  font-size: 1rem;
  line-height: 1.7;
  resize: none;
  field-sizing: content;
  min-height: calc(1.7em * 3 + 18px);
}

.insight-count {
  margin: 4px 0 0;
  text-align: right;
  color: var(--text-soft);
  font-size: 0.75rem;
}

.insight-count.is-full { color: var(--moving); }

/* 下載紀念圖 */
.btn-keep {
  display: block;
  margin: -6px auto 22px;
  padding: 8px 22px;
}

/* 牌卡放大檢視：點一下關閉 */
.card-zoom {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 5, 16, 0.92);
}

.card-zoom[hidden] { display: none; }

.card-zoom .hex-card {
  width: min(100%, calc((100vh - 32px) * 683 / 1024));
  width: min(100%, calc((100dvh - 32px) * 683 / 1024));
  max-width: 683px;
  border-radius: 8px;
  cursor: zoom-out;
  box-shadow: 0 0 40px rgba(214, 180, 106, 0.25);
}

.card-zoom .hex-card:hover { transform: none; }

body.zoom-open { overflow: hidden; }

.result-zhande {
  margin: 0 0 14px;
  text-align: center;
  color: var(--gold-bright);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-shadow: 0 0 20px rgba(240, 212, 142, 0.35);
}

.result-quiet {
  margin: -6px 0 16px;
  text-align: center;
  color: var(--text-soft);
}

.result-gua { margin-bottom: 14px; }

.gua-name {
  margin: 0 0 4px;
  color: var(--gold);
  font-weight: 700;
}

.gua-judgment {
  margin: 0;
  padding: 6px 12px;
  border-left: 2px solid var(--gold-soft);
  color: var(--text);
  font-size: 0.95rem;
}

.result-moving {
  margin: 0;
  color: var(--moving);
  font-weight: 700;
}

/* 複製區 */
.copy-area .panel-title { margin-bottom: 4px; }

.copy-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.copy-fail {
  margin: 0;
  color: var(--moving);
  font-size: 0.9rem;
}

.note-preview summary {
  cursor: pointer;
  color: var(--text-soft);
  padding: 4px 0;
}

.note-preview pre {
  margin: 8px 0 0;
  padding: 12px;
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--gold-faint);
  border-radius: 8px;
  background: var(--well);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* 手機：卦象縮小一點才放得下 */
@media (max-width: 420px) {
  .result-figures { gap: 10px; }
  .yao-lg { width: 60px; }
  .panel { padding: 22px 16px; }
}

@media (max-width: 360px) {
  .result-figures { gap: 6px; }
  .yao-lg { width: 50px; }
}

.nowrap { display: inline-block; }

@media (max-width: 380px) {
  body { font-size: 16px; }
  .site-title { font-size: 1.4rem; letter-spacing: 0.1em; }
  .tagline { letter-spacing: 0.35em; }
}

/* 卦典頁（gua.html） */
.site-title a {
  color: inherit;
  text-decoration: none;
}

.gua-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.gua-title {
  margin: 0;
  color: var(--cinnabar-light);
  font-size: 1.6rem;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-shadow: 0 0 18px rgba(208, 80, 63, 0.35);
}

.gua-trigrams {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
  letter-spacing: 0.3em;
}

.gua-head .figure { flex: none; }

.gua-card {
  max-width: 280px;
  margin: 0 auto;
}

.gua-card .hex-hint { margin-bottom: 0; }

.card-words {
  max-width: 360px;
  margin: 14px auto 24px;
  padding: 10px 8px;
  border-top: 1px solid var(--gold-soft);
  border-bottom: 1px solid var(--gold-soft);
  color: var(--gold-bright);
  font-size: 1.1rem;
  text-align: center;
}

.gua-section { margin-bottom: 20px; }

/* 原文：象曰、爻辭；爻題用古金色，和經文隔開 */
.gua-label {
  margin-right: 0.6em;
  color: var(--gold);
}

.gua-xiang {
  margin: 14px 0 0;
  padding: 0 12px;
  font-size: 0.95rem;
}

.gua-yao {
  margin: 14px 0 0;
  padding: 12px 12px 0;
  border-top: 1px solid var(--gold-soft);
  list-style: none;
  font-size: 0.95rem;
}

.gua-yao li {
  padding-left: 2.6em;
  text-indent: -2.6em;
}

.gua-yao li + li { margin-top: 8px; }

.gua-pending {
  margin: 0;
  color: var(--text-soft);
}

/* 解說：小標用古金色，段落之間留白；六爻白話不加上方分隔線 */
.gua-sub {
  margin: 18px 0 6px;
  color: var(--gold);
  font-size: 1rem;
  font-weight: normal;
  letter-spacing: 0.05em;
}

.gua-commentary > .gua-sub:first-child { margin-top: 0; }

.gua-commentary p { margin: 0; }

.gua-meaning { color: var(--gold-bright); }

.gua-yao-plain {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.gua-remind {
  padding: 10px 12px;
  border-left: 2px solid var(--gold-soft);
}

.gua-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.gua-nav-prev,
.gua-nav-next {
  color: var(--gold);
  text-decoration: none;
  line-height: 1.4;
}

.gua-nav-next { text-align: right; }

.gua-nav-prev:hover,
.gua-nav-next:hover { color: var(--gold-bright); }

.gua-nav-name {
  display: block;
  color: var(--text-soft);
  font-size: 0.85rem;
}

.gua-nav-home { grid-column: 2; text-decoration: none; }
.gua-nav-next { grid-column: 3; }

@media (max-width: 380px) {
  .gua-title { font-size: 1.3rem; letter-spacing: 0.04em; }
  .gua-head .yao-lg { width: 50px; }
}

/* 結果區卦名可點：新分頁打開卦典頁 */
.gua-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--gold-soft);
  text-underline-offset: 4px;
}

.gua-link:hover { color: var(--gold-bright); text-decoration-color: var(--gold); }

/* 首頁最下方「六十四卦」：8 欄 × 8 列，手機上也是 8 欄 */
.gua-index .panel-title { margin-bottom: 4px; }

.gua-index-hint {
  margin: 0 0 14px;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.gua-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gua-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 0 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.gua-cell:hover { border-color: var(--gold-soft); background: rgba(214, 180, 106, 0.08); }
.gua-cell:hover .gua-cell-name { color: var(--gold-bright); }
.gua-cell:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 1px; }

.mini-figure {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 20px;
}

.mini-yao {
  display: flex;
  justify-content: space-between;
  height: 3px;
}

.mini-yao i {
  display: block;
  height: 100%;
  background: var(--gold);
}

.gua-cell-name {
  font-size: 1.05rem;
  line-height: 1.6;
  white-space: nowrap;
}

/* 兩個字的卦名（小畜、噬嗑、既濟……）縮小，才放得進窄格 */
.gua-cell-name.is-long {
  font-size: 0.9rem;
  line-height: calc(1.05rem * 1.6);
}

@media (max-width: 440px) {
  .gua-cell-name.is-long { font-size: 0.8rem; letter-spacing: -0.02em; }
}

@media (max-width: 380px) {
  .gua-grid { gap: 2px; }
  .gua-cell-name.is-long { font-size: 0.75rem; }
}

/* 自選卦做紀念圖：選卦模式下，本卦／變卦格子加朱紅框、角上小字「本」「變」 */
.pick-toggle { display: block; margin: 0 0 12px; }

.gua-cell { position: relative; }

.gua-grid.is-picking .gua-cell { cursor: pointer; }

.gua-cell.is-picked,
.gua-cell.is-picked:hover {
  border-color: var(--cinnabar-light);
  background: rgba(176, 53, 42, 0.16);
}

/* 角標壓在格子右上角外緣，手機窄格也不會蓋到卦畫 */
.pick-mark {
  position: absolute;
  top: -6px;
  right: -4px;
  z-index: 1;
  padding: 2px 3px;
  border-radius: 3px;
  background: var(--cinnabar);
  color: #fdf6e8;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
}

.pick-mark:empty { display: none; }

.pick-preview { margin-top: 22px; }

.pick-preview .btn-keep { margin-bottom: 4px; }

/* 故事頁（story.html）：標題、四段故事、定裝照、靜心起卦 */
.story-title {
  margin: 4px 0 22px;
  color: var(--gold-bright);
  font-size: 1.45rem;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-align: center;
  text-shadow: 0 0 20px rgba(240, 212, 142, 0.35);
}

.story-section .panel-title { letter-spacing: 0.12em; }

.story-section p { margin: 0; }

.story-section p + p { margin-top: 12px; }

.story-section strong { color: var(--gold-bright); }

.story-photo {
  max-width: 260px;
  margin: 0 auto 18px;
}

.story-photo .hex-hint { margin-bottom: 0; }

.story-go {
  margin: 8px 0 0;
  text-align: center;
}

.story-go .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 32px;
  text-decoration: none;
}

@media (max-width: 380px) {
  .story-title { font-size: 1.25rem; letter-spacing: 0.06em; }
  .story-section .panel-title { letter-spacing: 0.06em; }
}

/* 從故事頁「靜心起卦 →」跳過來時，起卦資訊上緣留一點空，金框不被切到 */
#cast-info { scroll-margin-top: 16px; }
