:root {
  color-scheme: dark;
  --bg: #000;
  --text: #afafaf;
  --title: #eee;
  --border: #fff;
  --panel: rgba(10,10,10,.96);
  --selected: rgba(255,255,255,.12);
  --locked: .38;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Nanum Myeongjo", "Batang", serif; line-height: 1.72; }
button, input { font: inherit; }
.toolbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; background: rgba(0,0,0,.94); border-bottom: 1px solid #333; backdrop-filter: blur(12px); }
.toolbar button { color: #ddd; background: #111; border: 1px solid #555; border-radius: .35rem; padding: .35rem .7rem; cursor: pointer; }
.toolbar button:hover { border-color: #aaa; }
.toolbar-spacer { flex: 1; }
.point-bar { display: flex; flex-wrap: wrap; gap: .35rem .8rem; }
.point-item { display: flex; gap: .35rem; white-space: nowrap; font-size: .92rem; }
.point-name { color: #aaa; }
.point-value { color: #f2f2f2; }
#app { width: min(1560px, 100%); margin: 0 auto; padding: 1rem clamp(.6rem, 2vw, 2rem) 8rem; }
.cyoa-row { position: relative; margin: 2.5rem 0 5rem; scroll-margin-top: 5rem; text-align: center; }
.row-image { display: block; width: min(100%, 1536px); max-height: 78vh; object-fit: contain; margin: 0 auto 1.5rem; }
.row-title { color: var(--title); font-family: "Batang", serif; font-size: clamp(2rem, 5vw, 4.8rem); line-height: 1.15; margin: 1rem 0; font-weight: 700; }
.row-text { width: min(1050px, 100%); margin: 0 auto 2rem; font-size: clamp(1rem, 1.25vw, 1.24rem); }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.prose p { margin: .7em 0; }
.choice-groups { margin: -.8rem; }
.choice-row { display: flex; flex-wrap: wrap; align-items: stretch; width: 100%; margin: 0; }
.choice-row.standalone-line { justify-content: center; }
.choice-row.justify-center { justify-content: center; }
.choice-row.justify-space-around { justify-content: space-around; }
.choice-row.justify-space-between { justify-content: space-between; }
.choice-row.justify-start { justify-content: flex-start; }
.choice-row.justify-end { justify-content: flex-end; }
.choice-col { display: flex; flex: 0 0 var(--desktop-basis, 100%); max-width: var(--desktop-basis, 100%); padding: .8rem; }
.choice { position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; overflow: hidden; background: #080808; border: 5px double var(--border); border-radius: 2px; box-shadow: 8px 8px 18px 2px rgba(168,168,168,.24); cursor: pointer; text-align: center; transition: transform .15s ease, filter .15s ease, opacity .15s ease, background .15s ease; }
.choice:hover { transform: translateY(-2px); }
.choice.locked { filter: brightness(.7); opacity: var(--locked); }
.choice.not-selectable { cursor: default; }
.choice-image { display: block; width: 80%; max-height: 62vh; object-fit: contain; margin: 1rem auto 0; }
.choice-body { flex: 1 1 auto; padding: 1rem 1.2rem 1.35rem; }
.choice-title { margin: .25rem 0 .75rem; color: var(--title); font-size: clamp(1.25rem, 1.8vw, 2rem); line-height: 1.28; }
.choice-text { font-size: clamp(.9rem, 1vw, 1rem); }
.choice-scores { margin-top: 1rem; color: #eee; font-weight: 700; }
.requirement { margin-top: .8rem; color: #e4c4c4; font-size: .9rem; }
.addon { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid #444; }
.addon-image { width: min(100%, 520px); max-height: 55vh; object-fit: contain; }
.addon-title { color: #eee; font-size: 1.15rem; font-weight: 700; }
.addon-text { margin-top: .45rem; font-size: .92rem; }
.choice.has-multi-controls .choice-body { padding-bottom: .7rem; }
.multi-controls { display: flex; align-items: center; justify-content: center; gap: .65rem; min-height: 3.4rem; padding: .25rem .8rem 1rem; }
.multi-controls.counter-inversion-compensation { filter: invert(100%); }
.multi-count-text { color: #e00000; font-weight: 800; line-height: 1.2; text-shadow: 0 0 .15rem rgba(0,0,0,.5); }
.multi-count-text:empty { display: none; }
.multi-step-button { display: inline-grid; place-items: center; width: 2.35rem; height: 2.35rem; padding: 0; border: 1px solid #b80000; border-radius: 999px; background: #090909; color: #e00000; font-size: 1.45rem; font-weight: 800; line-height: 1; cursor: pointer; }
.multi-step-button:hover:not(:disabled) { background: #190000; border-color: #ff3030; color: #ff3030; }
.multi-step-button:disabled { opacity: .32; cursor: not-allowed; }
.side-panel { position: fixed; z-index: 60; top: 0; right: 0; width: min(390px, 92vw); height: 100vh; transform: translateX(100%); transition: transform .2s ease; background: var(--panel); border-left: 1px solid #555; overflow: auto; padding: 1rem; }
.panel-open .side-panel { transform: translateX(0); }
.side-panel h2 { color: #eee; margin-top: .2rem; }
.selected-panel { display: grid; gap: .35rem; }
.selected-item { text-align: left; color: #ddd; background: #111; border: 1px solid #444; padding: .5rem; cursor: pointer; }
.status { position: fixed; left: 50%; bottom: 1.3rem; z-index: 100; transform: translate(-50%, 150%); opacity: 0; transition: .2s; background: #eee; color: #111; padding: .65rem 1rem; border-radius: .3rem; }
.status.show { transform: translate(-50%, 0); opacity: 1; }
.bgm-frame { position: fixed; width: 1px; height: 1px; left: -20px; bottom: -20px; border: 0; }
@media (max-width: 1280px) {
  .choice-col { flex-basis: 50%; max-width: 50%; }
  .choice-col.choice-width-1 { flex-basis: 100%; max-width: 100%; }
}
@media (max-width: 960px) {
  .toolbar { align-items: flex-start; }
  .point-bar { max-height: 3.2rem; overflow: auto; }
}
@media (max-width: 480px) {
  .choice-col { flex-basis: 100%; max-width: 100%; }
  .toolbar button { padding: .3rem .45rem; font-size: .82rem; }
  .row-title { font-size: 2rem; }
}

/* Hotfix 005: BGM player and selection sound controls */
.toolbar { flex-wrap: wrap; }
.toolbar button:disabled { opacity: .38; cursor: not-allowed; border-color: #333; }
.audio-dock { display: grid; gap: .35rem; flex: 1 1 520px; min-width: 320px; max-width: 760px; padding-left: .75rem; border-left: 1px solid #333; }
.audio-now-playing { display: flex; align-items: baseline; gap: .55rem; min-width: 0; color: #ddd; }
.audio-label { flex: 0 0 auto; color: #888; font-size: .78rem; letter-spacing: .08em; }
#bgm-title { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; font-weight: 700; color: #d2d2d2; }
.audio-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.audio-actions button { padding: .24rem .55rem; font-size: .82rem; }
.volume-control { display: flex; align-items: center; gap: .35rem; min-width: 205px; color: #aaa; font-size: .8rem; }
.volume-control input[type="range"] { width: 120px; accent-color: #8c0000; cursor: pointer; }
.volume-control output { width: 2.8rem; text-align: right; color: #ddd; font-variant-numeric: tabular-nums; }
#sfx-toggle[aria-pressed="true"] { border-color: #7a2020; color: #e1caca; }
#sfx-toggle.is-off { color: #777; border-color: #444; }
.bgm-player-host { position: fixed; left: -10px; bottom: -10px; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

@media (max-width: 1100px) {
  .audio-dock { order: 3; flex-basis: 100%; max-width: none; padding: .5rem 0 0; border-left: 0; border-top: 1px solid #282828; }
  .toolbar-spacer { display: none; }
  .point-bar { margin-left: auto; }
}
@media (max-width: 620px) {
  .audio-dock { min-width: 100%; }
  .audio-now-playing { width: 100%; }
  .audio-actions { width: 100%; }
  .volume-control { order: 2; flex: 1 1 100%; }
  .volume-control input[type="range"] { flex: 1 1 auto; width: auto; }
}

/* Hotfix 006: sharp requirements, original image templates, spending meter */
.point-bar.spending-phase { align-items: flex-start; }
.point-bar.spending-phase .point-item { display: grid; grid-template-columns: auto auto; column-gap: .35rem; line-height: 1.15; }
.point-spending { grid-column: 1 / -1; color: #b06a6a; font-size: .7rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.choice-filter-target { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; width: 100%; }
.choice-layout { display: flex; flex: 1 1 auto; flex-direction: column; width: 100%; min-height: 0; }
.choice-image-box { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; min-width: 0; overflow: hidden; }
.choice-image { display: block; max-width: 100%; max-height: 62vh; object-fit: contain; }
.choice-body { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; }
.choice-requirements { flex: 0 0 auto; padding: 0 1.2rem 1.15rem; position: relative; z-index: 2; }
.choice-requirements .requirement { margin-top: .55rem; opacity: 1; filter: none; }
.choice.locked { filter: none; opacity: 1; }
.choice.locked:not(.has-explicit-req-filter) .choice-filter-target { opacity: var(--locked); }

@media (min-width: 1001px) {
  .choice-layout.image-left,
  .choice-layout.image-right { flex-direction: row; align-items: stretch; }
  .choice-layout.image-left .choice-image-box,
  .choice-layout.image-right .choice-image-box { flex-basis: var(--image-box-width, 50%); max-width: var(--image-box-width, 50%); }
  .choice-layout.image-left .choice-body,
  .choice-layout.image-right .choice-body { flex-basis: calc(100% - var(--image-box-width, 50%)); max-width: calc(100% - var(--image-box-width, 50%)); justify-content: center; }
  .choice-layout.image-right .choice-image-box { order: 2; }
  .choice-layout.image-right .choice-body { order: 1; }
}

@media (max-width: 1000px) {
  .choice-layout.image-left,
  .choice-layout.image-right { flex-direction: column; }
  .choice-layout.image-left .choice-image-box,
  .choice-layout.image-right .choice-image-box { order: -1; flex-basis: auto; max-width: 100%; width: 100%; }
  .choice-layout.image-left .choice-body,
  .choice-layout.image-right .choice-body { max-width: 100%; width: 100%; }
}

/* Hotfix 007: inline true-name entry */
.inline-text-entry {
  width: min(34rem, 100%);
  margin: 1.5rem auto .75rem;
  display: flex;
  align-items: stretch;
  gap: .65rem;
}
.inline-text-input {
  min-width: 0;
  flex: 1 1 auto;
  color: #eee;
  background: rgba(0, 0, 0, .78);
  border: 1px solid #777;
  border-radius: .2rem;
  padding: .75rem .9rem;
  text-align: center;
  outline: none;
}
.inline-text-input::placeholder { color: #777; }
.inline-text-input:focus {
  border-color: #ddd;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .18), 0 0 1.2rem rgba(255, 255, 255, .08);
}
.inline-text-confirm {
  flex: 0 0 auto;
  color: #ddd;
  background: #111;
  border: 1px solid #777;
  border-radius: .2rem;
  padding: .7rem 1rem;
  cursor: pointer;
}
.inline-text-confirm:hover,
.inline-text-confirm:focus-visible {
  color: #fff;
  border-color: #ddd;
}
@media (max-width: 620px) {
  .inline-text-entry { flex-direction: column; }
  .inline-text-confirm { width: 100%; }
}


/* Hotfix 008: independent BGM and selection-sound volume controls */
.audio-actions .volume-control { min-width: 225px; }
.audio-actions .volume-control > span { min-width: 4.3rem; white-space: nowrap; }
.sfx-volume-control { transition: opacity .15s ease; }
#sfx-toggle.is-off + .sfx-volume-control { opacity: .48; }
@media (max-width: 780px) {
  .audio-actions .volume-control { flex: 1 1 290px; min-width: 240px; }
  .audio-actions .volume-control input[type="range"] { flex: 1 1 auto; width: auto; }
}

/* Hotfix 010: escalating martial-style level prices. */
.choice-tier-price-label {
  margin-top: 0.7rem;
  margin-bottom: 0.2rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #b9b9b9;
}

/* Hotfix 011: row image templates and build-image export. */
.row-layout {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}
.row-image-box {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}
.row-image {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
}
.row-body {
  min-width: 0;
  flex: 1 1 auto;
}
#build-image-button {
  border-color: #6b2525;
  color: #e4cece;
}
#build-image-button:hover:not(:disabled) {
  border-color: #b34d4d;
  color: #fff;
}

@media (min-width: 1001px) {
  .row-layout.image-left,
  .row-layout.image-right {
    flex-direction: row;
    align-items: center;
  }
  .row-layout.image-left .row-image-box,
  .row-layout.image-right .row-image-box {
    flex-basis: var(--row-image-box-width, 40%);
    max-width: var(--row-image-box-width, 40%);
  }
  .row-layout.image-left .row-body,
  .row-layout.image-right .row-body {
    flex-basis: calc(100% - var(--row-image-box-width, 40%));
    max-width: calc(100% - var(--row-image-box-width, 40%));
  }
  .row-layout.image-left .row-text,
  .row-layout.image-right .row-text {
    width: 100%;
  }
  .row-layout.image-right .row-image-box { order: 2; }
  .row-layout.image-right .row-body { order: 1; }
}

@media (max-width: 1000px) {
  .row-layout.image-left,
  .row-layout.image-right {
    flex-direction: column;
  }
  .row-layout.image-left .row-image-box,
  .row-layout.image-right .row-image-box {
    order: -1;
    flex-basis: auto;
    max-width: 100%;
    width: 100%;
  }
  .row-layout.image-left .row-body,
  .row-layout.image-right .row-body {
    max-width: 100%;
    width: 100%;
  }
}

/* Hotfix 012: Ferm Magia rift event and persistent contracts. */
body.ferm-event-open { overflow: hidden; }
body.ferm-pink-death {
  background-color: #a80d65;
  background-image:
    radial-gradient(circle at 18% 16%, rgba(255, 179, 224, .45), transparent 24rem),
    radial-gradient(circle at 82% 30%, rgba(255, 36, 155, .38), transparent 30rem),
    linear-gradient(135deg, #5b003e 0%, #d31d83 52%, #74004c 100%);
  background-attachment: fixed;
}
body.ferm-pink-death .toolbar { background: rgba(70, 0, 42, .94); }
body.ferm-pink-death .cyoa-row { text-shadow: 0 1px 5px rgba(25, 0, 15, .75); }

.ferm-contract-banner {
  position: relative;
  z-index: 1;
  order: -10;
  display: flex;
  flex: 1 0 calc(100% + 1.6rem);
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .35rem 1.1rem;
  width: calc(100% + 1.6rem);
  margin: -.6rem -.8rem 0;
  padding: .48rem 1rem;
  color: #f0d9e8;
  background: linear-gradient(90deg, rgba(20, 0, 14, .98), rgba(74, 0, 48, .98), rgba(20, 0, 14, .98));
  border-bottom: 1px solid #a93575;
  box-shadow: 0 .25rem .8rem rgba(0, 0, 0, .48);
  text-align: center;
}
.ferm-contract-banner[hidden] { display: none; }
.ferm-contract-banner strong { color: #ff9fd4; letter-spacing: .04em; }
.ferm-contract-price { color: #d7c2cf; font-size: .88rem; }
.ferm-contract-lives { color: #ff4aa9; font-weight: 800; }

.ferm-event-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: clamp(.5rem, 2vw, 1.5rem);
  color: #ded2da;
  background:
    radial-gradient(circle at 50% 42%, rgba(110, 0, 72, .28), transparent 38rem),
    #000;
}
.ferm-event-overlay[hidden] { display: none; }
.ferm-event-overlay.ferm-death-scene {
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 191, 225, .56), transparent 26rem),
    linear-gradient(135deg, #5d003f, #ef2a94 54%, #8d0058);
}
.ferm-petal-layer,
.ferm-petal-layer::before,
.ferm-petal-layer::after {
  position: absolute;
  inset: -30%;
  pointer-events: none;
  content: '';
  background-image:
    radial-gradient(ellipse at center, rgba(255, 45, 153, .92) 0 34%, transparent 38%),
    radial-gradient(ellipse at center, rgba(115, 219, 196, .75) 0 28%, transparent 34%),
    radial-gradient(ellipse at center, rgba(255, 218, 231, .82) 0 30%, transparent 36%);
  background-size: 31px 19px, 43px 25px, 55px 32px;
  background-position: 4% 2%, 46% 12%, 81% 3%;
  opacity: .3;
  animation: ferm-petal-fall 16s linear infinite;
}
.ferm-petal-layer::before {
  transform: rotate(18deg) scale(.82);
  opacity: .23;
  animation-duration: 23s;
  animation-direction: reverse;
}
.ferm-petal-layer::after {
  transform: rotate(-13deg) scale(1.15);
  opacity: .16;
  animation-duration: 31s;
}
@keyframes ferm-petal-fall {
  from { translate: -3% -18%; rotate: 0deg; }
  to { translate: 7% 22%; rotate: 22deg; }
}

.ferm-event-panel {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: clamp(1rem, 3vw, 2.4rem);
  background: rgba(2, 1, 3, .92);
  border: 1px solid rgba(255, 82, 171, .55);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .8), 0 0 3rem rgba(222, 0, 118, .28);
  scrollbar-color: #8f1757 #080207;
}
.ferm-event-title {
  margin: 0 0 1rem;
  color: #ffb2d9;
  font-size: clamp(1.8rem, 4vw, 3.5rem);
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 0 1.2rem rgba(255, 0, 128, .42);
}
.ferm-event-image-box {
  display: flex;
  justify-content: center;
  margin: 0 auto 1.35rem;
}
.ferm-event-image {
  display: block;
  width: min(100%, 720px);
  max-height: 58vh;
  object-fit: contain;
  border: 1px solid rgba(255, 128, 193, .28);
  box-shadow: 0 0 2rem rgba(255, 0, 128, .16);
}
.ferm-event-prose {
  width: min(880px, 100%);
  margin: 0 auto;
  color: #d9cbd3;
  font-size: clamp(.98rem, 1.35vw, 1.16rem);
  line-height: 1.9;
  text-align: left;
}
.ferm-event-prose i { color: #f5dce9; }
.ferm-event-prose blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
  color: #ffb4da;
  border-left: 3px solid #d72982;
  background: rgba(98, 0, 55, .25);
}
.ferm-event-prose hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid rgba(255, 99, 181, .35);
}
.ferm-event-prose ul { padding-left: 1.35rem; }
.ferm-event-prose li { margin: .3rem 0; }

.ferm-answer-form {
  display: flex;
  width: min(680px, 100%);
  margin: 1.6rem auto 0;
  gap: .65rem;
}
.ferm-answer-input {
  min-width: 0;
  flex: 1 1 auto;
  padding: .8rem 1rem;
  color: #fff2f8;
  background: rgba(12, 0, 8, .92);
  border: 1px solid #8a3a66;
  outline: none;
  text-align: center;
}
.ferm-answer-input:focus {
  border-color: #ff72ba;
  box-shadow: 0 0 0 1px rgba(255, 114, 186, .25), 0 0 1.4rem rgba(255, 0, 128, .16);
}
.ferm-event-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .7rem;
  margin-top: 1.7rem;
}
.ferm-action-button,
.ferm-contract-card {
  color: #ead9e2;
  background: rgba(18, 2, 12, .94);
  border: 1px solid #793653;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.ferm-action-button {
  padding: .7rem 1.2rem;
}
.ferm-action-button.primary { border-color: #ce4b8c; color: #ffd8ec; }
.ferm-action-button:hover,
.ferm-action-button:focus-visible,
.ferm-contract-card:hover,
.ferm-contract-card:focus-visible {
  border-color: #ff79bc;
  background: rgba(72, 0, 42, .92);
  transform: translateY(-1px);
  outline: none;
}
.ferm-contract-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.ferm-contract-card {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-height: 14rem;
  padding: 1.1rem;
  text-align: left;
}
.ferm-contract-card strong {
  color: #ffafd7;
  font-size: 1.15rem;
  text-align: center;
}
.ferm-contract-effect { color: #d8c8d0; font-size: .9rem; line-height: 1.6; }
.ferm-contract-effect ul { margin: 0; padding-left: 1.2rem; }

@media (max-width: 760px) {
  .ferm-event-overlay { padding: 0; }
  .ferm-event-panel { width: 100%; max-height: 100vh; min-height: 100vh; border-left: 0; border-right: 0; }
  .ferm-event-image { max-height: 46vh; }
  .ferm-answer-form { flex-direction: column; }
  .ferm-contract-grid { grid-template-columns: 1fr; }
  .ferm-contract-card { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ferm-petal-layer,
  .ferm-petal-layer::before,
  .ferm-petal-layer::after { animation: none; }
}
.ferm-rule-note {
  width: min(820px, 100%);
  margin: 1rem auto 2rem;
  padding: .75rem 1rem;
  color: #ffb4da;
  background: rgba(77, 0, 45, .32);
  border: 1px solid rgba(222, 67, 143, .5);
  font-weight: 700;
  text-align: center;
}

/* Hotfix 017: cursor-trail white falling particles. */
.cursor-particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 44;
  display: block;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  opacity: .92;
  contain: strict;
}
#cursor-particle-toggle[aria-pressed="true"] {
  color: #eef2f6;
  border-color: #8996a3;
  box-shadow: inset 0 0 .7rem rgba(230, 240, 255, .08), 0 0 .45rem rgba(230, 240, 255, .08);
}
#cursor-particle-toggle.is-off {
  color: #777;
  border-color: #444;
  box-shadow: none;
}
@media (hover: none), (pointer: coarse) {
  #cursor-particle-toggle,
  .cursor-particle-canvas { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cursor-particle-canvas { display: none; }
}


/* Hotfix 018: fixed contract strip and classic build-code compatibility. */
body.build-code-open { overflow: hidden; }
.build-code-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: clamp(.6rem, 2vw, 1.5rem);
  background: rgba(0, 0, 0, .82);
  backdrop-filter: blur(8px);
}
.build-code-overlay[hidden] { display: none; }
.build-code-panel {
  width: min(1040px, 100%);
  max-height: min(92vh, 980px);
  overflow: auto;
  padding: clamp(1rem, 2.2vw, 1.7rem);
  color: #d8d0d5;
  background: linear-gradient(145deg, rgba(19, 14, 18, .99), rgba(5, 5, 5, .99));
  border: 1px solid #72505f;
  box-shadow: 0 1.2rem 4rem rgba(0, 0, 0, .72);
}
.build-code-title { margin: 0 0 .35rem; color: #f0e7ec; font-size: clamp(1.55rem, 3vw, 2.2rem); }
.build-code-help { margin: 0 0 1rem; color: #a99da4; font-size: .93rem; }
.build-code-textarea {
  display: block;
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: .85rem;
  color: #f1ecef;
  background: #070707;
  border: 1px solid #5b4a52;
  border-radius: .2rem;
  font-family: ui-monospace, "Cascadia Mono", "D2Coding", monospace;
  font-size: .9rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.build-code-textarea:focus { outline: 2px solid #9b4c75; outline-offset: 1px; }
.build-code-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.build-code-actions button {
  padding: .48rem .8rem;
  color: #ddd;
  background: #111;
  border: 1px solid #5b5156;
  border-radius: .3rem;
  cursor: pointer;
}
.build-code-actions button:hover { border-color: #aaa; }
.build-code-actions button.primary { color: #ffe3f1; border-color: #9c3e70; background: #321322; }
.build-code-report { margin-top: 1rem; }
.build-code-summary { margin: 0; padding: .65rem .8rem; border-left: 3px solid #666; background: rgba(255,255,255,.04); }
.build-code-summary.success { border-color: #4f9470; color: #cde7d6; }
.build-code-summary.warning { border-color: #b87838; color: #efd8bd; }
.build-code-warning-note { margin: .8rem 0 .35rem; color: #c7b4bd; }
.build-code-issue-list { margin: .35rem 0 0; padding-left: 1.35rem; }
.build-code-issue-list li { margin: .45rem 0; color: #cbbfc5; }
.build-code-issue-list strong { color: #f0d9e4; }
.build-code-ferm-note { margin: .9rem 0 0; padding: .6rem .75rem; color: #f0c8e0; border: 1px solid #7d315a; background: rgba(86, 18, 57, .28); }

@media (max-width: 620px) {
  .build-code-panel { padding: .9rem; }
  .build-code-textarea { min-height: 220px; font-size: .78rem; }
  .build-code-actions button { flex: 1 1 42%; }
}

/* Hotfix 021: right-side row navigator. */
.row-navigator {
  position: fixed;
  right: 0;
  bottom: 1rem;
  z-index: 55;
  width: min(248px, 86vw);
  min-height: 7rem;
  transform: translateX(100%);
  transition: transform .2s ease, opacity .18s ease;
  pointer-events: none;
}
.row-navigator[hidden] { display: none; }
.row-navigator.is-open { transform: translateX(0); }
.row-nav-toggle {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  min-width: 2.7rem;
  min-height: 7rem;
  padding: .75rem .45rem;
  border: 1px solid #6b5151;
  border-right: 0;
  border-radius: .55rem 0 0 .55rem;
  background: rgba(10, 7, 7, .96);
  color: #ded6d6;
  writing-mode: vertical-rl;
  letter-spacing: .1em;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: -5px 6px 18px rgba(0, 0, 0, .45);
}
.row-nav-toggle:hover,
.row-nav-toggle:focus-visible {
  color: #fff;
  border-color: #b68b8b;
  outline: none;
}
.row-nav-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 1rem - var(--row-nav-top, 0px));
  overflow: hidden;
  border: 1px solid #544343;
  border-right: 0;
  border-radius: .55rem 0 0 .55rem;
  background: rgba(5, 5, 5, .96);
  backdrop-filter: blur(12px);
  box-shadow: -10px 10px 28px rgba(0, 0, 0, .52);
  pointer-events: auto;
}
.row-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  min-height: 2.8rem;
  padding: .55rem .65rem .5rem .8rem;
  border-bottom: 1px solid #392d2d;
}
.row-nav-title {
  color: #eee;
  font-size: .94rem;
  letter-spacing: .08em;
}
.row-nav-close {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid #4b3d3d;
  border-radius: .25rem;
  background: #0d0d0d;
  color: #aaa;
  cursor: pointer;
}
.row-nav-close:hover { color: #fff; border-color: #8e6d6d; }
.row-nav-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
  flex: 0 0 auto;
  padding: .55rem .65rem;
  border-bottom: 1px solid #292323;
}
.row-nav-step {
  padding: .4rem .35rem;
  border: 1px solid #483939;
  border-radius: .3rem;
  background: #0d0d0d;
  color: #c8bcbc;
  cursor: pointer;
  font-size: .78rem;
}
.row-nav-step:hover:not(:disabled) { border-color: #916e6e; color: #fff; }
.row-nav-step:disabled { opacity: .3; cursor: default; }
.row-nav-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: .45rem .45rem .75rem;
  scrollbar-width: thin;
  scrollbar-color: #694747 #111;
}
.row-nav-item {
  display: grid;
  grid-template-columns: 2.3rem minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 2.45rem;
  margin: 0 0 .25rem;
  padding: .4rem .45rem .4rem .25rem;
  border: 1px solid transparent;
  border-radius: .28rem;
  background: transparent;
  color: #a9a1a1;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.row-nav-item:hover,
.row-nav-item:focus-visible {
  background: rgba(255, 255, 255, .055);
  border-color: #4b3b3b;
  color: #eee;
  outline: none;
}
.row-nav-item.is-active {
  background: rgba(91, 15, 34, .55);
  border-color: #98546a;
  color: #fff;
  box-shadow: inset 3px 0 0 #d08aa1;
}
.row-nav-number {
  color: #765e5e;
  font-family: ui-monospace, "Consolas", monospace;
  font-size: .69rem;
  text-align: center;
}
.row-nav-item.is-active .row-nav-number { color: #f0b1c5; }
.row-nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .78rem;
  line-height: 1.25;
}
.row-nav-empty { padding: 1.2rem .8rem; color: #777; text-align: center; font-size: .8rem; }
.panel-open .row-navigator {
  opacity: 0;
  pointer-events: none;
}
@media (max-width: 900px) {
  .row-navigator { width: min(280px, 86vw); }
  .row-nav-toggle { min-height: 6rem; font-size: .82rem; }
}
@media (prefers-reduced-motion: reduce) {
  .row-navigator,
  .row-nav-item { transition: none; }
}

/* Mobile edition: compact toolbar and fullscreen helper panels. */
html, body { max-width: 100%; overflow-x: hidden; }
.mobile-toolbar-toggle { display: none; }
.toolbar-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .6rem;
  flex: 1 1 auto;
  min-width: 0;
}
.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
}
.side-panel-header h2 { margin: 0; }
.side-panel-close {
  display: none;
  min-height: 2.5rem;
  padding: .45rem .9rem;
  color: #ddd;
  background: #111;
  border: 1px solid #555;
  border-radius: .35rem;
}
.mobile-edition .toolbar button,
.mobile-edition .row-nav-toggle,
.mobile-edition .row-nav-close,
.mobile-edition .row-nav-step,
.mobile-edition .row-nav-item,
.mobile-edition .build-code-actions button,
.mobile-edition .ferm-action-button,
.mobile-edition .ferm-contract-card,
.mobile-edition .inline-text-confirm,
.mobile-edition .side-panel-close {
  touch-action: manipulation;
}

@media (max-width: 820px) {
  .mobile-edition .toolbar {
    gap: .55rem;
    padding: .55rem .65rem;
    align-items: stretch;
  }
  .mobile-edition .toolbar.mobile-collapsed {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }
  .mobile-edition .mobile-toolbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: .5rem .8rem;
    font-size: .92rem;
    font-weight: 700;
    white-space: nowrap;
  }
  .mobile-edition .toolbar.mobile-collapsed .toolbar-main {
    display: none;
  }
  .mobile-edition .toolbar.mobile-expanded {
    display: flex;
    flex-direction: column;
  }
  .mobile-edition .toolbar.mobile-expanded .mobile-toolbar-toggle {
    align-self: flex-start;
  }
  .mobile-edition .toolbar.mobile-expanded .toolbar-main {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: .45rem;
    padding-top: .1rem;
    border-top: 1px solid #262626;
  }
  .mobile-edition .toolbar.mobile-expanded .toolbar-main > button,
  .mobile-edition .toolbar.mobile-expanded .toolbar-main > .audio-dock {
    width: 100%;
  }
  .mobile-edition .toolbar-spacer {
    display: none !important;
  }
  .mobile-edition .audio-dock {
    min-width: 100%;
    max-width: none;
    border-left: 0;
    padding-left: 0;
    padding-top: .25rem;
  }
  .mobile-edition .audio-now-playing { flex-wrap: wrap; }
  .mobile-edition #bgm-title {
    white-space: normal;
    line-height: 1.35;
  }
  .mobile-edition .audio-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
  }
  .mobile-edition .audio-actions button,
  .mobile-edition .volume-control {
    width: 100%;
    min-height: 2.75rem;
  }
  .mobile-edition .volume-control {
    display: grid;
    grid-template-columns: 4.8rem minmax(0, 1fr) 3rem;
    align-items: center;
    min-width: 0;
    padding: .15rem 0;
  }
  .mobile-edition .point-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .3rem .6rem;
    align-content: start;
    width: 100%;
    max-height: none;
    overflow: visible;
  }
  .mobile-edition .point-item {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: start;
    align-items: baseline;
    gap: .15rem .3rem;
    min-width: 0;
    font-size: .85rem;
  }
  .mobile-edition .point-spending {
    text-align: left;
    font-size: .68rem;
  }
  .mobile-edition #app {
    padding: .85rem .6rem 7rem;
  }
  .mobile-edition .cyoa-row {
    margin: 1.6rem 0 3rem;
    scroll-margin-top: 6rem;
  }
  .mobile-edition .row-title {
    margin: .6rem 0 .8rem;
    font-size: clamp(1.45rem, 8vw, 2.15rem);
  }
  .mobile-edition .row-text,
  .mobile-edition .choice-text,
  .mobile-edition .prose,
  .mobile-edition .ferm-event-prose {
    overflow-wrap: break-word;
    word-break: keep-all;
  }
  .mobile-edition .choice-row { margin: 0; }
  .mobile-edition .choice-col {
    padding: .45rem 0;
    flex-basis: 100%;
    max-width: 100%;
  }
  .mobile-edition .choice {
    box-shadow: 0 5px 14px rgba(168,168,168,.18);
    border-width: 3px;
  }
  .mobile-edition .choice-image {
    width: min(100%, 88vw);
    max-height: 42vh;
  }
  .mobile-edition .choice-body {
    padding: .85rem .95rem 1rem;
  }
  .mobile-edition .choice-title { font-size: 1.25rem; }
  .mobile-edition .choice-requirements { padding: 0 .95rem .95rem; }
  .mobile-edition .multi-controls { padding: .15rem .8rem .9rem; }
  .mobile-edition .side-panel {
    top: 0;
    width: 100vw;
    max-width: none;
    padding: .85rem;
    border-left: 0;
  }
  .mobile-edition .side-panel-close { display: inline-flex; align-items: center; justify-content: center; }
  .mobile-edition .selected-item {
    padding: .7rem;
    min-height: 2.8rem;
  }
  .mobile-edition .row-navigator {
    width: min(92vw, 320px);
    bottom: .75rem;
  }
  .mobile-edition .row-nav-toggle {
    min-width: 2.45rem;
    min-height: 5.2rem;
  }
  .mobile-edition .build-code-panel {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    padding: .95rem;
  }
  .mobile-edition .build-code-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .mobile-edition .build-code-actions button {
    min-height: 2.75rem;
  }
  .mobile-edition .status {
    width: min(92vw, 28rem);
    text-align: center;
  }
}

@media (max-width: 480px) {
  .mobile-edition .toolbar button,
  .mobile-edition .multi-step-button,
  .mobile-edition .side-panel-close,
  .mobile-edition .row-nav-step,
  .mobile-edition .row-nav-close,
  .mobile-edition .build-code-actions button {
    min-height: 2.75rem;
  }
  .mobile-edition .audio-actions {
    grid-template-columns: 1fr;
  }
  .mobile-edition .point-bar { grid-template-columns: 1fr 1fr; }
  .mobile-edition .volume-control { grid-template-columns: 4.5rem minmax(0, 1fr) 2.8rem; }
  .mobile-edition .row-nav-panel {
    max-height: min(70vh, calc(100vh - 4rem));
  }
}
