:root {
  color-scheme: light;
  --bg: #fff7fb;
  --ink: #2b2230;
  --muted: #695d66;
  --panel: rgba(255, 255, 255, 0.94);
  --line: #efc7d7;
  --brand: #cf0053;
  --brand-dark: #9f0043;
  --brand-soft: #efbdc4;
  --leaf: #26651e;
  --leaf-dark: #174615;
  --mint: #eef7e9;
  --sun: #f8b33c;
  --coral: #df705d;
  --shadow: 0 18px 45px rgba(111, 0, 47, 0.16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 8% 8%, rgba(239, 189, 196, 0.58), transparent 13rem),
    radial-gradient(circle at 92% 88%, rgba(38, 101, 30, 0.18), transparent 20rem),
    linear-gradient(135deg, var(--bg), #f4fbef 72%);
}

button,
input,
select {
  font: inherit;
}

.animal {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 18px 20px rgba(52, 31, 35, 0.18));
}

.animal-sloth {
  left: max(-220px, -12vw);
  bottom: -16px;
  width: clamp(250px, 27vw, 430px);
}

.animal-monkey {
  right: calc(100% - 100vw);
  top: 0;
  width: clamp(230px, 25vw, 390px);
  transform: scaleX(-1);
  transform-origin: top center;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
}

.story-picker,
.panel {
  background: var(--panel);
  border: 2px solid rgba(207, 0, 83, 0.16);
  box-shadow: var(--shadow);
}

.story-picker {
  border-radius: 8px;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 20px;
  align-items: start;
}

.brand-block {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.brand-logo {
  width: min(360px, 58vw);
  height: auto;
  display: block;
}

.story-control {
  align-self: start;
}

.kicker {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--brand-dark);
  font-size: clamp(1.7rem, 3.1vw, 3.2rem);
  line-height: 1.02;
}

.select-label {
  display: block;
  margin-bottom: 8px;
  color: var(--brand-dark);
  font-weight: 800;
}

.story-select,
.word-input {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.story-select {
  min-height: 52px;
  padding: 0 14px;
}

.story-select:focus,
.word-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(207, 0, 83, 0.16);
}

.word-input[aria-invalid="true"] {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px rgba(223, 112, 93, 0.18);
}

.workspace {
  display: grid;
}

.panel {
  border-radius: 8px;
  padding: clamp(20px, 4vw, 44px);
}

.progress-row,
.result-header,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.progress-label {
  color: var(--muted);
  font-weight: 800;
}

.progress-track {
  height: 12px;
  margin: 18px 0 34px;
  overflow: hidden;
  border-radius: 999px;
  background: #f4dce6;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--sun), var(--leaf));
  transition: width 180ms ease;
}

.prompt-card {
  max-width: 860px;
}

.prompt-prefix {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 800;
}

#prompt-label {
  margin-bottom: 10px;
  color: var(--brand);
  font-size: clamp(2.4rem, 7vw, 6rem);
  line-height: 0.98;
}

.prompt-help {
  min-height: 1.6em;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.word-input {
  min-height: 74px;
  padding: 10px 18px;
  font-size: clamp(1.6rem, 4vw, 3rem);
}

.input-error {
  min-height: 1.5em;
  margin: 10px 0 0;
  color: #a63f31;
  font-weight: 800;
}

.button-row {
  margin-top: 28px;
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0 22px;
  cursor: pointer;
  font-weight: 800;
}

button:focus-visible {
  outline: 4px solid rgba(207, 0, 83, 0.2);
  outline-offset: 3px;
}

.primary-button {
  min-width: 180px;
  color: #fff;
  background: var(--brand);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button,
.ghost-button {
  color: var(--brand-dark);
  background: #f8dfe9;
}

.secondary-button:hover,
.ghost-button:hover {
  background: #f0c8d7;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.result-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(255, 247, 251, 0.92)),
    linear-gradient(90deg, rgba(207, 0, 83, 0.11), rgba(38, 101, 30, 0.1));
}

.result-header {
  align-items: flex-start;
  margin-bottom: 28px;
}

.result-header h2 {
  margin-bottom: 0;
  color: var(--brand-dark);
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.story-output {
  max-width: 980px;
  font-size: clamp(1.35rem, 2.8vw, 2.45rem);
  line-height: 1.35;
}

.image-panel {
  margin-top: 28px;
}

.image-loading,
.image-error {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  border-radius: 8px;
  padding: 16px 18px;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 800;
}

.image-loading {
  color: var(--brand-dark);
  background: #f8dfe9;
}

.image-error {
  color: #8f3329;
  background: #ffe5df;
}

.spinner {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 4px solid rgba(207, 0, 83, 0.22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.generated-image {
  display: block;
  width: min(100%, 760px);
  max-height: 62vh;
  object-fit: contain;
  border: 3px solid rgba(207, 0, 83, 0.16);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 35px rgba(111, 0, 47, 0.14);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.filled-word {
  display: inline;
  padding: 0 0.16em;
  border-radius: 6px;
  background: rgba(239, 189, 196, 0.72);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  color: var(--brand-dark);
  font-weight: 800;
}

@media (max-width: 920px) {
  .animal-sloth {
    left: -160px;
    width: 280px;
    opacity: 0.6;
  }

  .animal-monkey {
    right: -150px;
    width: 270px;
    opacity: 0.6;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 10px 0;
    gap: 10px;
  }

  .story-picker {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .brand-logo {
    width: min(300px, 82vw);
  }

  .panel {
    padding: 18px;
  }

  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-button {
    min-width: 0;
  }

  .result-header {
    display: grid;
  }
}
