:root {
  --folio-paper: url('/assets/antique/paper-grain.webp');
  --folio-ink: #402414;
  --folio-gilt: #b88c4d;
  --folio-cream: #f8e4b9;
  --folio-leather: linear-gradient(135deg,#704529f0,#40291bf2 60%,#53301ff3);
}
body { background-color:#2d2016 }
[data-period="morning"] main.entry-overlay {
  --folio-light: radial-gradient(ellipse at 14% 67%,#f0c58b99,transparent 57%);
  --folio-ground:linear-gradient(155deg,#513a29ed,#a3764ad9 58%,#704a31e8);
  --ambient:#ae8459; --horizon:#9a6843;
}
[data-period="day"] main.entry-overlay {
  --folio-light:radial-gradient(ellipse at 88% 8%,#ffe0a1a8,transparent 54%);
  --folio-ground:linear-gradient(150deg,#6a4828ed,#ab8148df 46%,#674226ef);
  --ambient:#ae8850; --horizon:#886038;
}
[data-period="dusk"] main.entry-overlay {
  --folio-light:radial-gradient(ellipse at 92% 67%,#dc915e9c,transparent 57%);
  --folio-ground:linear-gradient(160deg,#44291ff2,#865235df 53%,#523222eb);
  --ambient:#9d6242; --horizon:#8c4930;
}
[data-period="night"] main.entry-overlay {
  --folio-light:radial-gradient(ellipse at 12% 10%,#bcb5a77a,transparent 47%);
  --folio-ground:linear-gradient(150deg,#43403bf2,#372e29eb 47%,#231c19f5);
  --ambient:#706759; --horizon:#44382f;
}
html[data-period] main.entry-overlay:not(.fortune-stage) {
  background-image:var(--home-arch,url('/assets/antique/arch-relief.webp')),
    radial-gradient(ellipse at 50% 44%,transparent 28%,#2b180e68 85%),
    var(--folio-light),var(--folio-ground),var(--home-paper,url('/assets/antique/worn-folio.webp'));
  background-blend-mode:normal,normal,normal,multiply,normal;
  background-size:min(100%,660px) 100%,cover,cover,cover,100% 100%;
  background-position:center;
  background-repeat:no-repeat;
  background-color:#392819;
}
.entry-head h1 { color:#f4ce84;text-shadow:0 1px 2px #361c10,0 2px 5px #361c1080 }
.entry-head :is(.book-brand,.book-prompt),.book-note { color:#f2dfb7;text-shadow:0 1px 3px #321c10 }
html body :is(.campaign-dialog,.home-screen-dialog,.fortune-caption) {
  color:var(--folio-cream);
  background:var(--folio-leather),var(--folio-paper) repeat;
  border-color:var(--folio-gilt);
  box-shadow:inset 0 0 0 2px #3b2216,inset 0 0 0 3px #b58b548c,0 12px 32px #1b100b70;
}
.install-header h2,#collection-dialog h3,#daily-dialog legend { color:#f4d295 }
html body .blessing-status:not(:empty) {background:var(--folio-leather),var(--folio-paper);border-color:var(--folio-gilt);color:var(--folio-cream)}
#daily-dialog :is(input,textarea) {
  background:linear-gradient(#f7e5c0dc,#ecd3a2de),var(--folio-paper);
  color:var(--folio-ink);border-color:#aa8046;caret-color:#663d23;
}
#daily-dialog :is(input,textarea)::placeholder { color:#785c40;opacity:1 }
#collection-grid .collection-locked,#rare-collection .collection-mystery {
  background:linear-gradient(135deg,#563824ed,#322117f5),var(--folio-paper);
  border-color:#a7824d;
}
#streak-lamps li:not(.lit) {background:#37261d}
.collection-badge {background-color:#dbb678;color:#482816}
#daily-status,#streak-status,.collection-special-note,.campaign-message {color:#f3d7a5}
.collection-quick-art,#daily-card {background-color:#37231b}

/* Nine-slice the carved rim so short prompts and scrolling folios share the same corners. */
html body dialog:is(.campaign-dialog,.home-screen-dialog),html body .fortune-caption {
  border: 9px solid #95692f;
  border-image: url('/assets/antique/dialog-relief.webp') 48 / 15px stretch;
  border-radius: 12px;
  background: radial-gradient(ellipse at 15% 0%,#f7e5c9b3,transparent 64%),
    linear-gradient(130deg,#ebd0a4dc,#e2c094d9 62%,#c79e6bdb),var(--folio-paper);
  color:var(--folio-ink);
  box-shadow:inset 0 0 15px #6a391f50,1px 4px 0 #55321e,0 13px 34px #21130980;
}
html body dialog::backdrop { background:#21150ed6 }
html body dialog .install-header {
  border-bottom:1px solid #aa804b;
  box-shadow:0 1px #fff0d096;
  padding-bottom:7px;
}
html body dialog .install-header h2, #collection-dialog h3,#daily-dialog legend,
#daily-dialog label,.install-progress,.home-screen-dialog .install-caption,
#daily-status,#streak-status,.collection-special-note,.campaign-message,#collection-page,
#daily-dialog :is(#family-fortune-hint,#family-blessing-hint),#collection-count { color:#52341d }
#daily-dialog :is(#family-fortune-error,#family-birthday-error) { color:#812b1c }
#collection-dialog :is(#rare-collection,#collection-grid) { gap:6px }
#collection-grid .collection-locked,#rare-collection .collection-mystery {
  background:linear-gradient(145deg,#684729eb,#392518f2),var(--folio-paper);
  box-shadow:inset 0 0 0 1px #382218,inset 0 0 0 2px #b890535e;
}
#collection-dialog .collection-pagination { border-block:1px solid #a77d4980; padding-block:5px }
#daily-dialog #daily-card,#daily-dialog .collection-quick-art,#invitation-poster {
  box-shadow:0 1px 0 #f9dfa6,1px 3px 8px #35200e66;
}
html body .fortune-caption :is(.fortune-message,.fortune-copy-hi,.rare-meaning) {color:#59351d}
html body .fortune-caption :is(a,button) .fortune-copy-hi {color:inherit}

/* Ink follows the surface underneath the text, including nested help panels. */
#campaign-dialog #campaign-reward,
#fortune-caption .fortune-link-note,
#fortune-caption .fortune-link-note .fortune-copy-hi { color:var(--folio-ink) }
#home-screen-dialog .install-demo .install-caption { color:#f8e4b9 }

html body dialog:is(#collection-dialog,#daily-dialog,#campaign-dialog,#channel-dialog,#home-screen-dialog,#home-share-dialog) {
  background: radial-gradient(ellipse at 48% 45%,#f8e5c368,transparent 85%),
    #dfbf90 url('/assets/antique/worn-folio.webp') center / 100% 100% no-repeat;
}
#home-screen-dialog .install-demo {
  background: linear-gradient(140deg,#57361bde,#302017ed),url('/assets/antique/worn-folio.webp') center / cover;
}
#home-screen-dialog .install-phone { background:#281d16; border-color:#91734e }
#home-screen-dialog :is(.install-webpage,.install-result) {
  background: radial-gradient(ellipse at 38% 35%,#775330ce,#39261ae8),url('/assets/antique/worn-folio.webp') center / cover;
}

/* The rare-card notice uses the same aged sheet as the collection folio. */
html body #fortune-caption {
  background: radial-gradient(ellipse at center,#f8e5c368,transparent 85%),
    #dfbf90 url('/assets/antique/worn-folio.webp') center / 100% 100% no-repeat;
}
html:lang(hi) .fortune-actions .fortune-copy-en,
html:lang(en) .fortune-actions .fortune-copy-hi { display:none }

html:is(:lang(en), :lang(hi)) .fortune-actions span { white-space:normal }
#fortune-caption .fortune-actions :is(a,button) span {
  color:#ffebbd;
  text-shadow:0 1px 2px #30190d;
}

/* The three toolbar buttons share their finish in both switch states. */
body :is(#music-toggle,#haptics-toggle,#home-share) {
  border-radius:50%;
  border:2px solid #c09a59;
  color:#ffebbd;
  background:#583820;
  box-shadow:inset 0 0 0 1px #432613,inset 0 0 0 2px #ad8450,0 2px 4px #28160eb3;
}
/* Mark an inactive switch without changing its colors. */
.home-tools :is(#music-toggle,#haptics-toggle)[aria-pressed="false"]::after {
  content:"";
  position:absolute;
  width:21px;
  height:2px;
  border-radius:2px;
  background:currentColor;
  transform:rotate(-45deg);
  pointer-events:none;
}

.home-tools { position:fixed; z-index:120; display:flex; gap:7px; top:max(8px,env(safe-area-inset-top)); right:max(8px,env(safe-area-inset-right)) }
.home-tools > .music-toggle { position:relative; inset:auto; width:44px; height:44px; padding:0; justify-content:center }
.home-tools > [hidden], .entry-overlay.fortune-stage ~ .home-tools #home-share { display:none }
#home-share-dialog #home-share-preview { width:100%; height:auto; max-height:58vh; object-fit:contain; margin:8px auto }
#home-share-send { width:100% }
#home-share-status { overflow-wrap:anywhere }
@media (max-width:380px) {
  #home-screen-button:not([hidden]) { max-width:calc(100vw - 178px); line-height:1.15 }
}


html:is([lang="en"],[lang="zh-CN"]) #entry-answer-en { display:none }
html:lang(zh) .share-en { display:inline }
html:lang(zh) .fortune-copy-zh { display:none }

#invite-destinations:not([hidden]) { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px }
#invite-destinations > * { flex:1 1 auto; display:grid; place-items:center; min-height:44px; padding:4px 10px; text-decoration:none; font:inherit; box-sizing:border-box }
#campaign-message { overflow-wrap:anywhere; user-select:text }

.book-tap-prompt { display:block; margin-top:2px; font-size:.86em; line-height:1.35; text-wrap:balance }

.entry-head .book-prompt {
  color:#f8e6c0;
  text-shadow:0 1px 2px #311c0e,0 0 3px #533018,0 0 8px #c28a3e55;
}
.book-tap-prompt .tap-instruction {
  color:#ffe3a0;
  font-weight:inherit;
  text-shadow:0 1px 2px #321c0d,0 0 3px #613515,0 0 5px #dea95388;
}
@media (prefers-reduced-motion:no-preference) {
  .book-tap-prompt .tap-instruction { animation:prompt-gold-light 3.2s ease-in-out .5s 2 }
  @keyframes prompt-gold-light {
    50% { color:#fff0c4; text-shadow:0 1px 2px #321c0d,0 0 3px #613515,0 0 8px #e0ae5ba3 }
  }
}

@media (max-width:600px) {
  .entry-overlay { --home-arch:url('/assets/antique/arch-mobile.webp'); --home-paper:url('/assets/antique/folio-mobile.webp') }
  .entry-overlay:not(.fortune-stage) .entry-dialog { width:min(78vw,480px); max-width:100%; min-width:0; box-sizing:border-box; padding-inline:0; margin-inline:auto; gap:clamp(4px,1vh,9px) }
  .entry-overlay:not(.fortune-stage) #entry-card { max-width:40vw }
  .entry-overlay:not(.fortune-stage) #prayer-lamps { box-sizing:border-box; width:100%; min-width:0 }
  .entry-overlay:not(.fortune-stage) .entry-head { max-width:100%; min-width:0 }
  .entry-overlay:not(.fortune-stage) .ritual-links { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:min(100%,375px); margin-inline:auto; gap:6px }
  .ritual-links button { min-height:44px; min-width:0; white-space:normal; line-height:1.25; padding-inline:5px }
  .entry-overlay:not(.fortune-stage) .home-screen-button { max-width:calc(100vw - 164px); white-space:normal }
}
@media (max-width:600px) and (max-height:690px) {
  .entry-overlay:not(.fortune-stage) { align-content:start }
  .entry-overlay:not(.fortune-stage) .entry-card { width:min(47vw,max(120px,calc((100vh - 340px)*.63))); width:min(47vw,max(120px,calc((100svh - 340px)*.63))) }
}
@media (max-width:600px) and (max-height:600px) {
  .entry-overlay:not(.fortune-stage) #entry-card { max-width:min(34vw,20vh); margin-block:2px 5px }
  .entry-overlay:not(.fortune-stage) .entry-dialog { gap:3px }
  .entry-overlay:not(.fortune-stage) #prayer-lamps button { height:56px }
}

/* Give the deck more of the page on tall phones while keeping its fan inside the arch. */
@media (max-width:600px) and (min-height:691px) and (orientation:portrait) {
  .entry-overlay:not(.fortune-stage) #entry-card {
    width:min(55vw,calc((100vh - 360px) * .62),300px);
    width:min(55vw,calc((100svh - 360px) * .62),300px);
    max-width:none;
    margin-block:clamp(6px,2vh,18px) clamp(12px,3vh,28px);
  }
  .entry-overlay:not(.fortune-stage) #entry-card::before { --fan-angle:-13deg }
  .entry-overlay:not(.fortune-stage) #entry-card::after { --fan-angle:13deg }
}

#channel-dialog .channel-copy { flex:1; min-width:0; text-align:start; line-height:1.5 }
#channel-dialog #channel-title { margin:0 0 .45em; color:#573219; font-size:1.25rem }
#channel-dialog .channel-copy p { margin:.35em 0; line-height:1.5 }
#channel-dialog #gate-clock, #card-clock {
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
#channel-dialog #gate-clock { color: #61452d; }
#gate-clock:empty { display: none; }
#card-clock {
  position: absolute;
  inset: auto 0 16%;
  z-index: 12;
  color: #553016;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 3.8vw, 1.25rem);
  font-weight: 600;
  letter-spacing: .08em;
  line-height: 1;
  pointer-events: none;
}
#card-clock:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
}
#card-clock::before, #card-clock::after {
  content: "";
  width: 1.35em;
  height: 1px;
  background: linear-gradient(to right, transparent, #855831);
}
#card-clock::after { transform: rotate(180deg); }
#channel-dialog #channel-ad-note { margin-top:.85em; font-size:.84rem; color:#61452d }

:is(#home-share-dialog,#campaign-dialog) .sharing-blessing {
  margin:8px auto 12px;
  color:#56351e;
  text-align:center;
  font-size:.94rem;
  line-height:1.5;
}
.sharing-blessing span { display:block; text-wrap:balance }
