:root {
  --bg: #f7eedc;
  --paper: var(--bg);
  --sheet: #fff9ed;
  --ink: #193824;
  --forest: #244632;
  --green: var(--forest);
  --muted: #535d4f;
  --line: #c4b99f;
  --accent: #944021;
  --orange: var(--accent);
  --mincho: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK JP", "Noto Serif JP", serif;
}

body {
  background-color: var(--paper);
  background-image: radial-gradient(ellipse at top, #fff9ed 0, transparent 60rem);
  color: var(--ink);
}

h1, h2, h3, .prose, .lead, .speech, .article, .dek, .quote, #epitaph {
  font-family: var(--mincho);
}

:where(a, button, summary, input):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.site-brand {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1em 0.8em;
  text-decoration: none;
}

.site-wordmark {
  font: 800 1.15rem/1.25 system-ui, sans-serif;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

.site-name {
  font: 700 0.95rem/1.6 var(--mincho);
  letter-spacing: 0;
}

.cover {
  max-width: 944px;
  margin: clamp(1.5rem, 5vw, 3.5rem) auto 0;
  padding: clamp(1.2rem, 5vw, 3.25rem);
  border: 3px double var(--forest);
  background-color: var(--sheet);
}

.cover h1 {
  max-width: 18em;
  margin: 0 0 0.35em;
  font-size: clamp(1.85rem, 5.2vw, 3.5rem);
  line-height: 1.45;
  letter-spacing: 0;
}

.cover-lead {
  margin: 0 0 1.6rem;
  font: 500 clamp(1rem, 2.2vw, 1.2rem)/1.85 var(--mincho);
}

.cover-villages {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--accent);
}

.cover-villages li {
  border-bottom: 1px solid var(--line);
}

.cover-villages a {
  display: grid;
  grid-template-columns: clamp(4.3rem, 18vw, 9rem) minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0.5rem;
  font: 700 clamp(1.1rem, 3vw, 1.5rem)/1.7 var(--mincho);
  text-decoration: none;
}

.village-illustration {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.cover-villages a:hover {
  background: #f1e7d3;
}

.cover-villages a span:last-child {
  color: var(--accent);
}

.cover .start-note {
  margin-top: 1rem;
  padding: 0;
}

.story-page .hero h1, .story-page .story-title {
  font: 700 clamp(1.85rem, 5vw, 3.625rem)/1.5 var(--mincho);
  letter-spacing: -0.03em;
  margin: 20px 0;
}

.story-title em {
  font-style: normal;
  color: var(--accent);
}

.story-page .hero {
  scroll-margin-top: 1.5rem;
}

.story-page .ledger {
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--line);
}

.story-page .ledger-title, .story-page .ledger small {
  color: var(--muted);
}

.story-page .ledger-metric {
  border-color: var(--line);
}

.story-page .choice, .record-card, .guide-page .villages a {
  background: var(--sheet);
  border-color: var(--line);
}

.story-page .choice {
  border-left: 2px solid var(--forest);
}

.story-page .choice strong, .ending-list h2, .record-heading strong {
  font-family: var(--mincho);
}

.story-page .choice:hover {
  background: #f1e7d3;
}

.jiya {
  border-radius: 0;
  box-shadow: none;
  background: var(--sheet);
}

.jiya-heading {
  background: transparent;
}

.jiya-heading button, .jiya-intervention > summary {
  min-height: 44px;
}

.jiya-kicker {
  display: none;
}

.jiya-intervention {
  display: block;
  padding: 0;
  margin: 1.25rem 0 1.75rem;
  border: 0;
  border-block: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.jiya-intervention > summary {
  padding: 0.55rem 0;
  color: var(--forest);
  font: 650 0.9rem/1.8 system-ui, sans-serif;
}

.jiya-intervention-content {
  padding: 0 0.75rem 1rem;
}

.jiya-introduction {
  display: grid;
  grid-template-columns: clamp(4.5rem, 16vw, 6.25rem) minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
  margin-bottom: 1rem;
}

.jiya-introduction p {
  margin: 0;
}

.jiya-portrait {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

.jiya-intervention .jiya-intervention-actions button {
  background: var(--sheet);
  color: var(--forest);
  border: 1px solid var(--line);
  border-radius: 0;
}

.jiya-intervention .jiya-intervention-actions button:hover {
  background: #f1e7d3;
}

.jiya-intervention .jiya-intervention-actions .jiya-continue {
  border-color: transparent;
  background: transparent;
}

.jiya-intervention.awaiting-reading {
  display: none;
}

@media (max-width: 1000px) {
  .cover {
    margin-inline: 22px;
  }
}

@media (max-width: 480px) {
  .site-name {
    font-size: 0.8rem;
  }

  .cover {
    margin-inline: 14px;
  }
}

.story-share {
  margin: 1.65rem 0 1.25rem;
  padding: 0.75rem 0;
}

.story-share summary {
  color: var(--forest);
  min-height: 44px;
  padding-block: 0.5rem;
}

.story-share-card {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin-block: 0.75rem 1.1rem;
  border: 1px solid var(--line);
}

.story-share label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 650;
}

.story-share textarea {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.65;
  resize: vertical;
}

.story-share .story-share-hint,
.story-share .story-share-status {
  margin: 0.65rem 0 0;
  color: var(--muted);
}

.story-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-block: 0.9rem 0.45rem;
}

.story-share-actions a, .story-share-actions button {
  min-height: 44px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--forest);
  background: var(--sheet);
  color: var(--forest);
  font: inherit;
  cursor: pointer;
}

.story-share-actions a { display: inline-flex; align-items: center; text-decoration: none; box-sizing: border-box; }
.story-share-actions a:hover, .story-share-actions button:hover {
  background: #f1e7d3;
}

.story-share-status:empty {
  margin: 0;
}

.story-share { max-width: 36rem; }
.story-share-card { max-width: 100%; box-sizing: border-box; }
.share-field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 .6rem;
}
.share-field-heading button, .story-share-actions button {
  background: transparent;
  border: 0;
  color: var(--forest);
  text-decoration: underline;
  text-underline-offset: .22em;
  font: inherit;
  font-size: .875rem;
  min-height: 44px;
  padding: .35rem .4rem;
  cursor: pointer;
}
.share-field-heading button:disabled { opacity: .5; cursor: default; }
.story-share-actions[role="group"] {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
}
.share-destination-label {
  grid-column: 1 / -1;
  font-weight: bold;
  color: var(--forest);
}
.story-share-actions a {
  justify-content: center;
  background: var(--forest);
  color: white;
  font-weight: bold;
}
.story-share-actions a:hover { background: #305840; }
.story-share :focus-visible, .story-page .choice:focus-visible {
  outline: 3px solid #97432f;
  outline-offset: 3px;
}
.story-page .choice {
  min-height: 48px;
  border-left: 4px solid var(--forest);
  padding: .85rem 1rem;
}
.story-page .choice strong { color: var(--forest); }

.story-page .choice-intro {
  font-size: 1.1rem;
  margin-block: 1.6rem .65rem;
}
.story-page .choice {
  position: relative;
  cursor: pointer;
  padding-inline-end: 2.8rem;
  box-shadow: 0 2px 0 var(--line);
}
.story-page .choice::after {
  content: "";
  position: absolute;
  inset-inline-end: 1.15rem;
  top: 50%;
  width: .5rem;
  height: .5rem;
  border-top: 2px solid var(--forest);
  border-right: 2px solid var(--forest);
  transform: translateY(-50%) rotate(45deg);
}
.story-page .choice:focus-visible { background: #e9eddf; }
.story-page .choice:active { box-shadow: none; transform: translateY(2px); }

.story-page :is(.cover-villages a, .next-village, [data-restart], .jiya-intervention-actions button, .jiya-questions button) {
  cursor: pointer;
}
.story-page :is(.cover-villages a, .next-village, [data-restart], .jiya-intervention-actions button, .jiya-questions button):not(:disabled):active {
  box-shadow: none;
  transform: translateY(2px);
}

.story-page header .header-links { align-items: center; flex-wrap: wrap; }
.header-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-inline-start: auto;
}
.header-actions .sound-settings { margin: 0; }
.header-account {
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
}
.sound-settings {
  position: relative;
  border: 0;
  padding: 0;
  margin: 0 0 0 auto;
  font: inherit;
}
:is(.sound-settings, .header-account) > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  color: var(--forest);
  white-space: nowrap;
}
:is(.sound-settings, .header-account) > summary::-webkit-details-marker { display: none; }
:is(.sound-settings, .header-account)[open] > summary,
:is(.sound-settings, .header-account) > summary:hover { background: #e9eddf; }
.sound-settings > div, .header-account-panel {
  position: absolute;
  inset-inline-end: 0;
  inset-block-start: calc(100% + .4rem);
  z-index: 3;
  font: 14px/1.5 system-ui, sans-serif;
  width: min(16rem, 75vw);
  display: grid;
  gap: .65rem;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffbf2;
  box-shadow: 0 4px 16px #223b2420;
}
:is(.sound-settings, .header-account):not([open]) > div { display: none; }
.header-account-panel {
  width: min(17rem, 80vw);
}
.header-account-panel > a, .header-account-buttons button {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.header-account-buttons { display: grid; gap: .45rem; }
.header-account-panel p { margin: 0; }
.header-account-panel p:empty { display: none; }
.sound-settings input { accent-color: var(--forest); }
.sound-settings input[type=range] { display: block; width: 100%; margin: .4rem 0; }
.sound-settings button { justify-self: start; cursor: pointer; padding: .25rem .7rem; }

.jiya-intervention > summary {
  display: inline-flex;
  gap: .65rem;
  align-items: center;
  padding: .4rem .8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}
.jiya-intervention > summary::-webkit-details-marker { display: none; }
.jiya-intervention > summary:hover { background: #e9eddf; }
.jiya-seal {
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: #4c6a59;
}
.jiya-seal::before {
  content: "";
  width: 55%;
  height: 55%;
  border: 1px solid currentColor;
  transform: rotate(45deg);
  background: radial-gradient(circle, currentColor 1px, transparent 2px);
}
.jiya-seal.summoning { animation: jiya-seal-glow .65s ease-out; }
.jiya-portrait-frame { position: relative; isolation: isolate; }
.jiya-intervention[open] .jiya-portrait {
  animation: jiya-portrait-reveal .65s ease-out both;
}
.jiya-intervention[open] .jiya-portrait-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 65%, #fff5ff, #b885e1 55%, transparent 78%);
  animation: jiya-portrait-light .65s ease-out both;
}
@keyframes jiya-portrait-reveal {
  0% { opacity: 0; transform: translateY(5px); }
  25% { opacity: .25; filter: brightness(1.35); }
  100% { opacity: 1; transform: translateY(0); filter: none; }
}
@keyframes jiya-portrait-light {
  0%, 100% { opacity: 0; }
  30% { opacity: .65; }
}
@keyframes jiya-seal-glow {
  25% { color: #705194; background: #f4e8ff; box-shadow: 0 0 12px 4px #b885e1; }
}
.jiya-intervention .jiya-greeting { font-weight: 700; margin-bottom: .25rem; min-height: 1.9em; }
.jiya-intervention .jiya-skip { min-height: 32px; padding: .15rem .55rem; font-size: .8rem; }
.jiya-intervention .jiya-skip[hidden] { display: none; }
.jiya-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  .jiya-seal.summoning { animation: none; }
  .jiya-intervention[open] .jiya-portrait { animation: none; box-shadow: 0 0 0 2px #b885e1; }
  .jiya-intervention[open] .jiya-portrait-frame::after { content: none; }
  .story-page :is(.choice, .cover-villages a, .next-village, [data-restart], .jiya-intervention-actions button, .jiya-questions button):active { transform: none; }
}
.cover-villages a span:last-child { font-size: 1.15em; }
