:root {
  color-scheme: dark;
  --ink: #f5f1e8;
  --muted: #c8d0ca;
  --panel: #171b1c;
  --panel-strong: #202629;
  --line: rgba(255, 255, 255, 0.16);
  --accent: #72ff39;
  --accent-strong: #a5ff68;
  --accent-shadow: #208b2d;
  --focus: #7dd3fc;
  font-family: "Trebuchet MS", Trebuchet, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    conic-gradient(from 210deg at 52% 48%, #254de0, #ff4fb1, #6b87ff, #fd75c7, #254de0),
    #1f2a83;
  background-attachment: fixed;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.splash-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 205, 120, 0.2), transparent 38%),
    linear-gradient(rgba(8, 7, 5, 0.1), rgba(8, 7, 5, 0.4)),
    url("assets/splash-wood-planks-lighter.png") center / cover no-repeat,
    #1a120c;
}

.language-button {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 1;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid rgba(255, 241, 205, 0.7);
  border-radius: 999px;
  background: rgba(61, 37, 22, 0.9);
  color: #fff0cb;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.language-button:hover {
  background: #79471f;
}

.language-dialog {
  width: min(660px, calc(100vw - 32px));
  border: 1px solid #c9995f;
  border-radius: 24px;
  padding: 24px;
  color: #fff2dc;
  background: #2a1a10;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.language-dialog::backdrop {
  background: rgba(8, 5, 3, 0.7);
}

.language-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.language-dialog h2 {
  margin: 0;
  font-size: 1.6rem;
}

.language-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 2rem;
  line-height: 1;
}

.language-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.language-grid button {
  min-height: 48px;
  border: 1px solid #8f6942;
  border-radius: 14px;
  background: #422817;
  color: inherit;
}

.language-grid button:hover,
.language-grid button:focus-visible {
  background: #76431f;
  border-color: #ffd38f;
}

.splash-banner {
  width: min(920px, 100%);
  min-height: 280px;
  display: grid;
  place-items: center;
  gap: 28px;
  align-content: center;
  padding: clamp(44px, 8vw, 84px) clamp(70px, 10vw, 120px);
  border: 0;
  background: url("assets/summary-scroll-transparent.png") center / 100% 100% no-repeat;
  box-shadow: none;
  text-align: center;
}

#splashPage {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  gap: 16.8px;
  padding-top: 80px;
}

.home-introduction {
  width: min(920px, 100%);
  margin: 0;
  padding: 18px 22px;
  border: 1px solid rgba(109, 60, 25, 0.45);
  border-radius: 12px;
  background: rgba(255, 239, 198, 0.8);
  color: #3b2515;
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.6;
  text-align: center;
  text-wrap: pretty;
}

.splash-banner h1 {
  margin: 0;
  max-width: 760px;
  color: #dc143c;
  font-size: clamp(2.53rem, 7.36vw, 5.98rem);
  line-height: 0.95;
  letter-spacing: 0;
  text-wrap: balance;
  text-shadow: none;
}

.splash-banner h1 .title-word,
.menu-banner h2 .title-word {
  white-space: nowrap;
}

.splash-banner h1 .title-letter,
.menu-banner h2 .title-letter {
  display: inline-block;
  padding-bottom: 0.2em;
  margin-bottom: -0.2em;
  background: linear-gradient(to right, #dc143c, #800020);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.menu-banner h2 {
  grid-column: 1 / -1;
  margin: 0;
  max-width: 760px;
  color: #dc143c;
  font-size: clamp(2.2rem, 6vw, 4.75rem);
  line-height: 1;
  text-wrap: balance;
}

.menu-banner {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.menu-function-button {
  width: 100%;
  min-width: 0;
  min-height: clamp(128px, 16vw, 184px);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
}

.splash-button {
  min-width: 156px;
  padding: 0 28px;
  border-radius: 999px;
}

.is-hidden {
  display: none;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  min-height: 100vh;
  background:
    linear-gradient(rgba(8, 7, 5, 0.18), rgba(8, 7, 5, 0.5)),
    url("assets/splash-wood-planks-lighter.png") center / cover no-repeat,
    #1a120c;
}

.app.is-hidden {
  display: none;
}

.scene-panel {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(rgba(8, 7, 5, 0.32), rgba(8, 7, 5, 0.62)),
    url("assets/splash-wood-planks-lighter.png") center / cover no-repeat,
    #111719;
}

.home-button { position: absolute; top: 18px; right: 18px; z-index: 2; width: 100.1px; height: 100.1px; border: 0; padding: 21.7px 16.8px 28.7px; color: #050505; background: url("assets/home-shield.png") center / contain no-repeat; font-size: 0.945rem; font-weight: 800; line-height: 1; text-shadow: 0 1px 2px rgba(255, 232, 157, 0.72); filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.45)); }
.home-button:hover { filter: brightness(1.12) drop-shadow(0 5px 6px rgba(0, 0, 0, 0.5)); }
.scene-panel .download-button { position: absolute; top: 130.1px; right: 25.5075px; z-index: 2; width: 85.085px; height: 85.085px; padding: 56.525px 8.33px 8.925px; border: 0; background: url("assets/download-quill-parchment.png") center / contain no-repeat; color: #291604; font-size: 7.14px; font-weight: 800; line-height: 1.15; text-shadow: 0 1px 2px #ffe6af; box-shadow: none; transform: none; filter: drop-shadow(0 4px 5px #0007); }
.scene-panel .download-button:hover:not(:disabled) { filter: brightness(1.12) drop-shadow(0 5px 6px #0007); transform: translateY(-2px); }
.scene-panel .download-button:active:not(:disabled) { transform: translateY(1px); }
.scene-panel .download-button:disabled { opacity: .5; cursor: not-allowed; }
.scene-panel .download-button:hover,
.scene-panel .download-button:active { background: url("assets/download-quill-parchment.png") center / contain no-repeat; box-shadow: none; }

.initial-scene-image {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100vh;
}

.initial-scene-image {
  object-fit: cover;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: clamp(20px, 4vw, 42px);
  background:
    radial-gradient(circle at 38% 8%, rgba(255, 205, 120, 0.16), transparent 36%),
    linear-gradient(rgba(8, 7, 5, 0.12), rgba(8, 7, 5, 0.52)),
    url("assets/splash-wood-planks-lighter.png") center / cover no-repeat,
    #1a120c;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(125px, 1fr) minmax(0, 193px);
  gap: 3px 10px;
  align-items: center;
}

#primaryInterface .toolbar,
#characterInterface .toolbar ,
#plotAnchorInterface .toolbar {
  grid-template-columns: max-content minmax(0, 193px);
  column-gap: 5px;
}

#primaryInterface .toolbar > label,
#primaryInterface .custom-interior-field > label,
#characterInterface .toolbar > label,
#plotAnchorInterface .toolbar > label,
#characterInterface .custom-interior-field > label ,
#plotAnchorInterface .custom-interior-field > label {
  white-space: nowrap;
  overflow-wrap: normal;
}

.control-top {
  display: grid;
  grid-template-columns: minmax(0, 65fr) minmax(0, 35fr);
  gap: 10px;
  align-items: stretch;
}

.custom-interior-field {
  display: contents;
}

.custom-interior-field[hidden] {
  display: none;
}

.randomize-button {
  font-size: 1rem;
}

label {
  min-width: 0;
  color: #ffdd57;
  font-size: clamp(1rem, 2.2vw, 1.36rem);
  font-weight: 700;
  justify-self: stretch;
  text-align: center;
  overflow-wrap: anywhere;
}

input,
select {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 0 12px;
}

input::placeholder {
  color: rgba(200, 208, 202, 0.58);
}

select {
  width: 193px;
  height: 32px;
  padding: 0 9px;
  font-size: 0.9rem;
}

.generate-button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  width: 100%;
  height: calc(100% - 16px);
  min-height: 0;
  justify-self: center;
  align-self: center;
  font-size: 1.55rem;
  line-height: 1;
}

#generateButton .generate-word,
#characterGenerateButton .generate-word ,
#objectGenerateButton .generate-word {
  white-space: nowrap;
}

#generateButton .generate-letter,
#characterGenerateButton .generate-letter ,
#objectGenerateButton .generate-letter {
  display: inline-block;
  padding-bottom: 0.2em;
  margin-bottom: -0.2em;
  background: linear-gradient(to bottom, #9ed8ff, #4682b4);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.9));
}

.option-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.randomize-button,
.reset-options-button {
  min-height: 76px;
  padding: 0 18px;
  font-size: 1.3125rem;
}

#continueButton,
#storySettingButton,
#characterGeneratorButton,
#randomizeButton,
#characterRandomizeButton,
#objectRandomizeButton,
#generateButton,
#characterGenerateButton,
#objectGenerateButton,
#resetOptionsButton,
#characterResetButton ,
#objectResetButton {
  background: #0b2f66;
  color: #ffffff;
  border-color: #6f95d8;
  box-shadow: 0 6px 0 #061d3f, 0 12px 24px rgba(2, 13, 30, 0.38);
}

/* Keep the welcome button's raised edge rounded as well as its face. */
#continueButton {
  width: clamp(269.1px, 29.9vw, 328.9px);
  min-width: 269.1px;
  height: clamp(284.909625px, 32.207175vw, 346.8465px);
  padding: 59.4594px 80.73px 52.026975px 41.86px;
  border-radius: 0;
  border-color: transparent;
  background: url("assets/generate-flagon-button.png") center / 100% 100% no-repeat;
  color: #fff1c7;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  line-height: 1.15;
  text-wrap: balance;
  text-shadow: 0 2px 3px #170801, 0 0 10px #170801;
  box-shadow: none;
  filter: drop-shadow(0 8px 7px rgba(18, 7, 2, 0.62));
}

#continueButton:hover,
#storySettingButton:hover,
#characterGeneratorButton:hover,
#randomizeButton:hover,
#characterRandomizeButton:hover,
#objectRandomizeButton:hover,
#generateButton:hover,
#characterGenerateButton:hover,
#objectGenerateButton:hover,
#resetOptionsButton:hover,
#characterResetButton:hover ,
#objectResetButton:hover {
  background: #123f82;
  box-shadow: 0 8px 0 #061d3f, 0 15px 28px rgba(2, 13, 30, 0.42);
}

#continueButton:hover {
  border-color: transparent;
  background: url("assets/generate-flagon-button.png") center / 100% 100% no-repeat;
  box-shadow: none;
  filter: brightness(1.12) drop-shadow(0 10px 8px rgba(18, 7, 2, 0.7));
}

#continueButton:active,
#storySettingButton:active,
#characterGeneratorButton:active,
#randomizeButton:active,
#characterRandomizeButton:active,
#objectRandomizeButton:active,
#generateButton:active,
#characterGenerateButton:active,
#objectGenerateButton:active,
#resetOptionsButton:active,
#characterResetButton:active ,
#objectResetButton:active {
  box-shadow: 0 1px 0 #061d3f, 0 5px 14px rgba(2, 13, 30, 0.34);
}

#continueButton:active {
  border-color: transparent;
  background: url("assets/generate-flagon-button.png") center / 100% 100% no-repeat;
  box-shadow: none;
  filter: brightness(0.94) drop-shadow(0 4px 4px rgba(18, 7, 2, 0.58));
}

#storySettingButton {
  border-color: transparent;
  background: url("assets/story-setting-tome-red.png") center / contain no-repeat;
  color: #fff1c7;
  box-shadow: none;
  filter: drop-shadow(0 8px 7px rgba(18, 7, 2, 0.6));
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  text-shadow: 0 2px 3px #170801, 0 0 10px #170801;
}

#storySettingButton:hover {
  border-color: transparent;
  background: url("assets/story-setting-tome-red.png") center / contain no-repeat;
  box-shadow: none;
  filter: brightness(1.12) drop-shadow(0 10px 8px rgba(18, 7, 2, 0.68));
}

#storySettingButton:active {
  background: url("assets/story-setting-tome-red.png") center / contain no-repeat;
  box-shadow: none;
  filter: brightness(0.94) drop-shadow(0 4px 4px rgba(18, 7, 2, 0.58));
}

#characterGeneratorButton {
  border-color: transparent;
  background: url("assets/character-boots-medieval-transparent.png") center / contain no-repeat;
  color: #fff1c7;
  box-shadow: none;
  filter: drop-shadow(0 8px 7px rgba(18, 7, 2, 0.6));
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  text-shadow: 0 2px 3px #170801, 0 0 10px #170801;
}

#characterGeneratorButton:hover {
  border-color: transparent;
  background: url("assets/character-boots-medieval-transparent.png") center / contain no-repeat;
  box-shadow: none;
  filter: brightness(1.12) drop-shadow(0 10px 8px rgba(18, 7, 2, 0.68));
}

#characterGeneratorButton:active {
  background: url("assets/character-boots-medieval-transparent.png") center / contain no-repeat;
  box-shadow: none;
  filter: brightness(0.94) drop-shadow(0 4px 4px rgba(18, 7, 2, 0.58));
}

#generateButton,
#generateButton:hover,
#generateButton:active,
#characterGenerateButton,
#objectGenerateButton,
#characterGenerateButton:hover,
#objectGenerateButton:hover,
#characterGenerateButton:active ,
#objectGenerateButton:active {
  border-color: transparent;
  background: url("assets/generate-flagon-button.png") center / contain no-repeat;
  box-shadow: none;
  color: #9ed8ff;
  text-shadow: 0 3px 7px rgba(0, 0, 0, 0.9);
}

#randomizeButton,
#randomizeButton:hover,
#randomizeButton:active,
#characterRandomizeButton,
#objectRandomizeButton,
#characterRandomizeButton:hover,
#objectRandomizeButton:hover,
#characterRandomizeButton:active ,
#objectRandomizeButton:active {
  display: grid;
  place-items: center;
  border-color: transparent;
  background: url("assets/randomize-lattice-button.png") center / 100% 100% no-repeat;
  box-shadow: none;
  color: #69ef9b;
  line-height: 1.05;
  text-align: center;
  text-shadow: none;
}

#randomizeButton .randomize-letter,
#characterRandomizeButton .randomize-letter ,
#objectRandomizeButton .randomize-letter {
  display: inline-block;
  background: linear-gradient(to bottom, #dcffe8 0%, #69ef9b 50%, #249c62 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.95));
}

#resetOptionsButton,
#resetOptionsButton:hover,
#resetOptionsButton:active,
#characterResetButton,
#objectResetButton,
#characterResetButton:hover,
#objectResetButton:hover,
#characterResetButton:active ,
#objectResetButton:active {
  position: relative;
  display: grid;
  place-items: start center;
  overflow: hidden;
  padding-top: 3px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: #c0392b;
  text-shadow: 0 3px 7px rgba(0, 0, 0, 0.9);
}

#resetOptionsButton::before,
#characterResetButton::before ,
#objectResetButton::before {
  content: "";
  position: absolute;
  inset: 28px 0 auto;
  z-index: 0;
  height: 48px;
  background: url("assets/reset-sword-button.png") center / 100% 100% no-repeat;
  pointer-events: none;
}

#resetOptionsButton > span,
#characterResetButton > span ,
#objectResetButton > span {
  position: relative;
  z-index: 1;
  line-height: 1;
  white-space: nowrap;
  transform: translate(28px, 18px);
  background: linear-gradient(to bottom, #f07868 0%, #c0392b 50%, #80261d 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.9));
}

.summary-actions {
  display: block;
}

button {
  height: 44px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  background: var(--accent);
  color: #071807;
  border-color: #dbffc5;
  box-shadow: 0 6px 0 var(--accent-shadow), 0 12px 24px rgba(9, 45, 24, 0.34);
  transform: translateY(-4px);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button:hover,
.secondary-button:hover {
  background: var(--accent-strong);
  transform: translateY(-6px);
  box-shadow: 0 8px 0 var(--accent-shadow), 0 15px 28px rgba(9, 45, 24, 0.38);
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(-1px);
  box-shadow: 0 1px 0 var(--accent-shadow), 0 5px 14px rgba(9, 45, 24, 0.32);
}

.description-card {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 16px;
}

.setting-summary {
  min-height: 56px;
  display: grid;
  place-items: center;
  padding: 14px 46px;
  border: 0;
  border-radius: 6px;
  background: url("assets/summary-scroll-transparent.png") center / 100% 100% no-repeat;
  color: #6d1010;
  box-shadow: none;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.22;
  text-align: center;
  text-transform: capitalize;
}

.description-window {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
}

.setting-lock-button {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: 54px;
  height: 54px;
  padding: 4px;
  border: 1px solid rgba(233, 196, 106, 0.55);
  border-radius: 8px;
  background: rgba(12, 31, 23, 0.82);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.38);
}

.setting-lock-button:hover {
  background: rgba(22, 47, 34, 0.94);
}
.setting-lock-button:disabled { opacity: .45; cursor: not-allowed; }

.setting-lock-button[aria-pressed="true"] {
  border-color: rgba(255, 219, 132, 0.9);
  background: rgba(40, 30, 22, 0.94);
}

.setting-lock-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

textarea {
  flex: 1;
  min-height: 460px;
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f2a1d;
  color: var(--ink);
  padding: 80px 18px 76px;
  font-family: "Trebuchet MS", Trebuchet, Arial, sans-serif;
  font-size: 1.05rem;
  line-height: 1.58;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .scene-panel {
    min-height: 42vh;
  }

  .initial-scene-image {
    min-height: 42vh;
  }

  .controls-panel {
    min-height: 58vh;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  textarea {
    min-height: 420px;
  }
}

@media (max-width: 500px) {
  #splashPage {
    min-height: 100svh;
    padding: 68px 16px 12px;
    gap: 7px;
  }

  #splashPage .splash-banner {
    min-height: 0;
    gap: 10px;
    padding: 22px 32px;
  }

  #splashPage .home-introduction {
    padding: 12px 14px;
    line-height: 1.35;
  }

  .control-top {
    grid-template-columns: 1fr;
  }

  .generate-button {
    min-height: 96px;
  }

  .option-actions {
    grid-template-columns: 1fr;
  }

}
@media (max-width: 500px) and (max-height: 740px) {
  #splashPage #continueButton {
    height: 170px;
    width: 200px;
    min-width: 200px;
    padding: 35px 48px 31px 25px;
  }
}

/* Optional premium illustration controls */
.render-options { margin-top: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.render-options h3 { margin: 0; }
.render-options small { font-size: 12px; border: 1px solid currentColor; border-radius: 20px; padding: 3px 8px; margin-inline-start: 8px; }
.render-options p { line-height: 1.5; }
.render-options input { display: block; box-sizing: border-box; width: 100%; margin: 8px 0 12px; padding: 10px; }
.render-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.render-actions button { padding: 12px; flex: 1; }
.render-actions button:disabled { opacity: .5; cursor: not-allowed; }
.premium-entry-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 14px; margin-top: 0; }
.premium-code-field h3 { margin-bottom: 10px; }
.premium-code-field, .premium-entry-row .render-actions { min-width: 0; }
.premium-entry-row input { margin-bottom: 0; min-width: 0; min-height: 48px; }
.premium-entry-row .fresh-button,
.premium-entry-row .fresh-button:hover,
.premium-entry-row .fresh-button:active { min-width: 0; min-height: 72px; transform: none; background: #090617 url("assets/generate-dark-void.png") center / cover no-repeat; color: #fff; border: 1px solid #9c82c7; text-shadow: 0 2px 4px #000, 0 0 8px #000; box-shadow: 0 3px 12px #160b3066; }
.premium-entry-row .fresh-button:hover:not(:disabled) { filter: brightness(1.18); }
.premium-entry-row .fresh-button { box-sizing: border-box; position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }
.premium-entry-row .render-actions { position: relative; display: block; width: 68%; aspect-ratio: 1 / 1; justify-self: center; }
.premium-code-field { align-self: start; display: flex; flex-direction: column; }
.premium-code-field p { margin: 0 0 10px; }
.premium-code-field label { margin-top: 0; }
.image-only-options .premium-entry-row { grid-template-columns: minmax(0, 1fr); }
.prose-premium-controls { display: flex; align-items: center; gap: 12px; padding: 12px; background: #0f2a1d; border-radius: 8px 8px 0 0; }
.prose-premium-controls .setting-lock-button { position: static; flex: 0 0 54px; }
.prose-premium-controls .fresh-button { flex: 1; min-width: 0; min-height: 48px; padding: 6px 12px; transform: none; background: #090617 url("assets/generate-dark-void.png") center / cover no-repeat; color: #fff; border: 1px solid #9c82c7; text-shadow: 0 2px 4px #000; }
.prose-premium-controls .fresh-button,
.prose-premium-controls .fresh-button:hover,
.prose-premium-controls .fresh-button:active {
  box-shadow: none;
  transform: none;
}
#primaryInterface .description-window, #characterInterface .description-window ,
#plotAnchorInterface .description-window { display: flex; flex-direction: column; }
#primaryInterface .description-window textarea, #characterInterface .description-window textarea ,
#plotAnchorInterface .description-window textarea { padding-top: 18px; }
.premium-code-button,
.premium-code-button:hover,
.premium-code-button:active {
  align-self: start;
  width: min(168px, 100%);
  height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0;
  background: transparent;
  color: #fff1c7;
  border: 0;
  border-radius: 11px;
  font-size: 1.5rem;
  line-height: 24px;
  text-shadow: 0 2px 2px #170801, 0 0 5px #170801, 0 0 10px #170801;
  box-shadow: none;
}
.premium-code-button::before {
  content: "";
  display: block;
  flex: 0 0 71.4px;
  width: 85%;
  background: url("assets/premium-code-coins-trimmed.png") center / contain no-repeat;
  border-radius: 11px;
}
.premium-code-button:hover { filter: brightness(1.12); }
.premium-code-button:focus-visible { outline: 3px solid #ffd38f; outline-offset: 4px; }
.premium-code-dialog { width: min(420px, calc(100vw - 32px)); }
.premium-code-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.premium-code-header h2 { margin: 0; }
.premium-code-close { flex: 0 0 48px; width: 48px; height: 48px; padding: 0; display: grid; place-items: center; font-size: 32px; line-height: 1; color: #fff2dc; background: #513420; border: 1px solid #c9995f; touch-action: manipulation; }
.premium-code-close:hover { background: #70482c; }
.premium-code-close:focus-visible { outline: 3px solid #ffd38f; outline-offset: 3px; }
.premium-code-dialog input { width: 100%; min-height: 48px; margin-bottom: 20px; }
.premium-code-dialog .render-actions { margin-top: 12px; }
@media (max-width: 480px) { .premium-entry-row { grid-template-columns: minmax(0, 1fr); } }
.render-status { margin: 10px 0 0; font-size: 28px; }
.render-status:empty { display: none; }
.scene-panel .render-status { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 4; width: min(440px, calc(100% - 32px)); margin: 0; padding: 18px; border: 1px solid #9c82c7; border-radius: 10px; background: rgba(15, 10, 27, .95); color: #fff; box-shadow: 0 8px 32px #0006; text-align: center; line-height: 1.5; overflow-wrap: anywhere; }
.replacement-warning { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 5; box-sizing: border-box; width: min(440px, calc(100% - 32px)); padding: 16px; border: 2px solid #b7791f; border-radius: 10px; background: #fff3cd; color: #513600; box-shadow: 0 8px 32px #0006; text-align: center; line-height: 1.5; }
.replacement-warning[hidden] { display: none; }
.replacement-warning p { margin-top: 0; font-weight: 600; }
.account-button { position:fixed; left:22px; top:22px; z-index:50; min-height:40px; padding:0 18px; background:#38291b; color:#ffe6ab; border:1px solid #bb955a; border-radius:8px; cursor:pointer; }
#accountDialog { width:min(520px, calc(100vw - 40px)); max-height:85vh; overflow:auto; background:#f3e5c5; color:#302319; border:2px solid #886536; border-radius:12px; padding:24px; }
#accountDialog::backdrop { background:#0009; }
#accountDialog form label { display:block; margin:14px 0; color:#17365d; }
#accountDialog input:not([type=checkbox]) { display:block; width:100%; box-sizing:border-box; padding:10px; margin-top:5px; }
#accountDialog button, #accountDialog select { padding:8px 12px; margin:4px; }
#accountDialog [hidden] { display:none !important; }
#accountStatus { min-height:1.5em; }
.account-user { border-top:1px solid #af946d; padding:10px 0; overflow-wrap:anywhere; }
.account-user label { display:inline-block; color:#17365d; }
.premium-signin-notice { position:absolute; top:50%; left:50%; transform:translate(-50%, -50%); z-index:5; width:min(440px, calc(100% - 32px)); padding:56px 20px 20px; border:1px solid #9c82c7; border-radius:10px; background:rgba(15, 10, 27, .95); color:#fff; box-shadow:0 8px 32px #0006; text-align:center; font-size:28px; line-height:1.5; overflow-wrap:anywhere; }
.premium-signin-notice[hidden] { display:none; }
.premium-signin-notice p { margin:0; }
.premium-notice-close { position:absolute; top:4px; right:4px; width:48px; height:48px; padding:0; display:grid; place-items:center; font-size:36px; line-height:1; border:1px solid #9c82c7; border-radius:8px; background:#30213f; color:#fff; cursor:pointer; touch-action:manipulation; }
.premium-notice-close:focus-visible { outline:3px solid var(--focus); outline-offset:2px; }

#randomizeButton .randomize-word,
#characterRandomizeButton .randomize-word ,
#objectRandomizeButton .randomize-word { white-space: nowrap; }

#plotAnchorButton {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 12px 20px 18px;
  background: transparent;
  border: 0;
  border-radius: 18px;
  box-shadow: none;
  color: #fff1c7;
  text-shadow: 0 2px 4px #000;
  min-height: 140px;
}
#plotAnchorButton .plot-anchor-lantern {
  display: block;
  width: clamp(140px, 18vw, 220px);
  height: clamp(140px, 18vw, 220px);
  object-fit: contain;
  filter: drop-shadow(0 5px 8px #0008);
}
#plotAnchorButton:hover { background: #ffffff0d; }
#plotAnchorButton:hover .plot-anchor-lantern { filter: brightness(1.12) drop-shadow(0 5px 10px #65cfff55); }
#plotAnchorButton span { display: block; line-height: 1.2; }

/* Keep the premium explanation beside its code control on every tool. */
.image-only-options .premium-code-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, 168px);
  column-gap: 14px;
  align-items: start;
}
.image-only-options .premium-code-field h3,
.image-only-options .premium-code-field > p { grid-column: 1; overflow-wrap: anywhere; }
.image-only-options .premium-code-field .premium-code-button {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 112px;
  white-space: normal;
}
.image-only-options .premium-code-field .render-status { grid-column: 1 / -1; }
/* Compact premium panels and scale their code controls to 90%. */
.image-only-options.render-options { padding: 10px; }
.image-only-options .premium-code-field {
  grid-template-columns: minmax(0, 1fr) minmax(90px, 151.2px);
  column-gap: 10px;
}
.image-only-options .premium-code-field h3 { margin-bottom: 6px; }
.image-only-options .premium-code-field > p { margin-bottom: 0; }
.image-only-options .premium-code-field .premium-code-button,
.image-only-options .premium-code-field .premium-code-button:hover,
.image-only-options .premium-code-field .premium-code-button:active {
  min-height: 100.8px;
  height: auto;
  gap: 1.8px;
  font-size: 1.35rem;
  line-height: 21.6px;
  border-radius: 9.9px;
}
.image-only-options .premium-code-button::before { flex-basis: 64.26px; }
.image-only-options .premium-code-field .render-status:empty { display: none; }
/* Reserve space above the story-tool scroll for the Home control. */
#menuPage {
  padding-top: 140px;
  align-content: start;
  gap: 24px;
}
#plotAnchorButton {
  grid-column: 1 / -1;
  justify-self: center;
  width: calc((100% - 28px) / 2);
}
.menu-banner {
  row-gap: 10px;
}
#storySettingButton,
#storySettingButton:hover,
#storySettingButton:active,
#characterGeneratorButton,
#characterGeneratorButton:hover,
#characterGeneratorButton:active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 12px 20px 18px;
  background: transparent;
  border: 0;
  border-radius: 18px;
}
#storySettingButton::before,
#characterGeneratorButton::before {
  content: '';
  display: block;
  flex: 0 0 auto;
  width: clamp(140px, 18vw, 220px);
  height: clamp(140px, 18vw, 220px);
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
}
#storySettingButton::before { background-image: url('assets/story-setting-tome-red.png'); }
#characterGeneratorButton::before { background-image: url('assets/character-boots-medieval-transparent.png'); }
/* Reveal the full image boxes, including transparent padding. */
#storySettingButton::before,
#characterGeneratorButton::before {
  background-color: #f2e6cf;
  outline: 1px solid #6d4a28;
}
/* Preserve the full-resolution artwork without enlarged background cropping. */
#storySettingButton::before,
#characterGeneratorButton::before {
  background-color: transparent;
  outline: none;
  width: clamp(140px, 18vw, 220px);
  height: clamp(140px, 18vw, 220px);
  aspect-ratio: auto;
  background-size: contain;
  background-position: center;
  image-rendering: auto;
}
/* Bring labels closer while keeping artwork at its original display scale. */
#storySettingButton::before,
#characterGeneratorButton::before {
  margin-bottom: -24px;
}
#storySettingButton::before { margin-bottom: -28px; }

#plotAnchorButton {
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  color: #fff1c7;
  text-shadow: 0 2px 3px #170801, 0 0 10px #170801;
}
#plotAnchorButton span { font-weight: inherit; line-height: inherit; }
/* Each grapheme receives its own blue gradient, like the main title. */
.menu-function-button .tool-button-label { display: block; text-shadow: none; line-height: 1.2; }
.menu-function-button .tool-label-word { display: inline; white-space: nowrap; }
.menu-function-button .tool-label-letter {
  display: inline-block;
  padding-bottom: 0.2em;
  margin-bottom: -0.2em;
  background: linear-gradient(to right, #000080, #4682b4);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}
#plotAnchorButton .tool-label-word { display: inline; }
#plotAnchorButton .tool-label-letter { display: inline-block; }

#plotAnchorButton .plot-anchor-lantern {
  width: clamp(130.2px, 16.74vw, 204.6px);
  height: clamp(130.2px, 16.74vw, 204.6px);
}
.generator-publisher { margin-top: auto; padding-top: 12px; text-align: center; color: var(--text, #fff1c7); font-size: 0.9rem; line-height: 1.4; }

/* Anchor overlays to the viewport rather than a scrolled preview panel. */
.scene-panel .render-status,
.replacement-warning,
.premium-signin-notice {
  position: fixed;
  inset: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  box-sizing: border-box;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  box-sizing: border-box;
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.admin-accounts-button { position:absolute; top:80px; left:18px; z-index:2; padding:10px 18px; }
.admin-accounts-button[hidden] { display:none; }
.admin-accounts-dialog { width:min(850px,calc(100vw - 32px)); padding:24px; color:#fff1c7; background:#21170f; border:1px solid #ac8756; border-radius:12px; }
.admin-accounts-dialog label { display:block; margin:12px 0; }
.admin-accounts-dialog input,.admin-accounts-dialog select { display:block; width:100%; box-sizing:border-box; padding:10px; margin-top:5px; }
.admin-account-row { padding:14px 0; border-bottom:1px solid #ac8756; overflow-wrap:anywhere; }
.admin-account-row h3 { margin:0; }
.admin-accounts-dialog button { padding:10px 16px; }

.popup-close { position:absolute; top:6px; right:6px; width:44px; height:44px; display:grid; place-items:center; padding:0; font-size:28px; line-height:1; z-index:2; color:#fff; background:#30213f; border:1px solid #9c82c7; border-radius:8px; cursor:pointer; }
.popup-close:focus-visible { outline:3px solid #ffd38f; outline-offset:2px; }
dialog:has(> .popup-close), .replacement-warning, .scene-panel .render-status { padding-top:58px; }
.scene-panel .render-status[hidden] { display:none; }
.render-message { margin:0; }

/* Premium generation shares the free generator's flagon artwork. */
.image-only-options .premium-code-field .premium-generate-button,
.image-only-options .premium-code-field .premium-generate-button:hover,
.image-only-options .premium-code-field .premium-generate-button:active {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 100%;
  height: auto;
  min-height: 150px;
  padding: 22px 8px;
  gap: 6px;
  border-color: transparent;
  background: url("assets/generate-flagon-button.png") center / contain no-repeat;
  box-shadow: none;
  color: #9ed8ff;
  font-size: 1.15rem;
  line-height: 1.15;
  text-shadow: 0 3px 7px rgba(0,0,0,.9);
}
.premium-generate-button span { max-width: 120px; }
.premium-generate-button:hover:not(:disabled) { filter: brightness(1.12); }

/* Balance prose controls around the centered premium image action. */
.prose-premium-controls {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  column-gap: 12px;
}
.prose-premium-controls .fresh-button { width: 100%; }
.prose-premium-controls .prose-download-button,
.prose-premium-controls .prose-download-button:hover,
.prose-premium-controls .prose-download-button:active {
  width: 54px;
  height: 54px;
  min-height: 54px;
  padding: 0;
  border: 0;
  background: url("assets/download-quill-parchment.png") center / contain no-repeat;
  box-shadow: none;
  transform: none;
  filter: drop-shadow(0 4px 5px #0007);
}
.prose-premium-controls .prose-download-button:hover:not(:disabled) { filter: brightness(1.12) drop-shadow(0 4px 5px #0007); }
.prose-premium-controls .prose-download-button:disabled { opacity: .45; cursor: not-allowed; }

.prose-scroll-prompt {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  min-height: 32px;
  padding: 5px 14px;
  border: 1px solid #d6bb7b;
  border-radius: 18px;
  background: #153b2f;
  color: #fff3cf;
  font-size: .85rem;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 2px 6px #0005;
  cursor: pointer;
}
.prose-scroll-prompt[hidden] { display: none; }
.prose-scroll-prompt:hover { background: #22543f; }
.prose-scroll-prompt:focus-visible { outline: 3px solid #ffd38f; outline-offset: 2px; }

.prose-premium-controls .prose-download-button { position: relative; }
.prose-save-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  color: #000;
  -webkit-text-fill-color: #000;
  font-family: Georgia, serif;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .3px;
  text-align: center;
  text-shadow: none;
}
