.demo-page {
  background:
    radial-gradient(40rem 28rem at 16% 10%, rgba(91, 147, 255, 0.13), transparent 62%),
    radial-gradient(34rem 24rem at 84% 12%, rgba(255, 90, 60, 0.12), transparent 64%),
    var(--bg);
}

.demo-main {
  padding-top: var(--header-h);
  padding-bottom: clamp(3rem, 8vh, 6rem);
}

.demo-hero {
  padding: 4.2rem 0 2rem;
}

.demo-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 2rem;
  align-items: end;
}

.demo-copy h1 {
  margin-top: 0.45rem;
  font-family: var(--font-display);
  font-size: 2.8rem;
  line-height: 1.35;
  font-weight: 400;
}

.demo-copy p:last-child {
  max-width: 40rem;
  margin-top: 1rem;
  color: var(--muted);
}

.demo-status-card {
  border: 2px dashed rgba(243, 236, 221, 0.28);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  background: rgba(33, 28, 23, 0.74);
  color: var(--muted);
  transform: rotate(1deg);
}

.demo-status-card strong,
.demo-status-card span {
  display: block;
}

.demo-status-card strong {
  margin: 0.2rem 0;
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
}

.demo-status-label {
  color: var(--gold);
  font-weight: 800;
  font-size: 0.8rem;
}

.demo-workspace {
  padding-top: 1.5rem;
  padding-bottom: clamp(4rem, 10vh, 7rem);
}

.demo-grid {
  display: grid;
  grid-template-columns: minmax(20rem, 1.02fr) minmax(19rem, 0.98fr);
  gap: 1.5rem;
  align-items: start;
}

.draw-panel,
.result-panel {
  min-width: 0;
}

.draw-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: rgba(28, 24, 20, 0.78);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.36);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 0.9rem;
}

.panel-head h2,
.empty-result h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.45;
  font-weight: 400;
}

.tool-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.tool-group {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 17, 14, 0.62);
}

.tool-button,
.generate-button {
  min-height: 2.5rem;
  border: 2px solid rgba(243, 236, 221, 0.24);
  border-radius: 8px;
  padding: 0.42rem 0.85rem;
  color: var(--cream);
  background: rgba(243, 236, 221, 0.06);
  font: inherit;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.tool-button:not(:disabled):hover,
.generate-button:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: var(--cream);
}

.tool-button.is-active {
  color: var(--bg);
  background: var(--gold);
  border-color: var(--gold);
}

.tool-button.is-primary {
  color: var(--bg);
  background: var(--gold);
  border-color: var(--gold);
}

.tool-button.danger {
  color: #fff;
  background: rgba(255, 90, 60, 0.18);
  border-color: rgba(255, 90, 60, 0.62);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(9, 2.25rem);
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.swatch {
  width: 2.25rem;
  height: 2.25rem;
  border: 3px solid rgba(20, 17, 14, 0.75);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(243, 236, 221, 0.22), 0 3px 0 rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.swatch.is-active {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.swatch-white {
  box-shadow: 0 0 0 1px rgba(20, 17, 14, 0.65), 0 3px 0 rgba(0, 0, 0, 0.4);
}

.canvas-shell {
  position: relative;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border: 4px solid var(--cream);
  border-radius: 8px;
  background:
    linear-gradient(rgba(20, 17, 14, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 17, 14, 0.05) 1px, transparent 1px),
    #fffdf4;
  background-size: 32px 32px;
  box-shadow: inset 0 0 0 2px rgba(20, 17, 14, 0.14), 0 14px 32px rgba(0, 0, 0, 0.4);
}

#drawCanvas,
#cursorCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 4px;
}

#drawCanvas {
  touch-action: none;
  cursor: none;
}

#cursorCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.submit-area {
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  margin-top: 1rem;
}

.turnstile-box {
  min-height: 4.1rem;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.generate-button {
  min-width: 11rem;
  color: #fff;
  background: var(--red);
  border-color: var(--cream);
  font-family: var(--font-display);
  font-weight: 400;
}

.generate-button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

.tool-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.demo-message {
  grid-column: 1 / -1;
  min-height: 1.5rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.demo-consent {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.demo-consent a {
  color: var(--cream);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.demo-message.is-error {
  color: var(--red);
}

.result-panel {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}

.empty-result[hidden],
.beast-card[hidden],
.beast-stage img[hidden],
.generation-overlay[hidden],
.name-dialog[hidden],
.reveal-flash[hidden],
.confetti-canvas[hidden] {
  display: none !important;
}

.empty-result {
  border: 1px dashed rgba(243, 236, 221, 0.24);
  border-radius: 8px;
  min-height: 22rem;
  display: grid;
  align-content: center;
  gap: 0.5rem;
  padding: 2rem;
  color: var(--muted);
  background: rgba(33, 28, 23, 0.58);
}

.beast-card {
  display: grid;
  gap: 0.85rem;
}

.card-paper {
  display: grid;
  grid-template-columns: minmax(8rem, 0.9fr) minmax(0, 1.1fr);
  gap: 1rem;
  align-items: stretch;
  padding: 1rem;
  border: 3px solid #4c3824;
  border-radius: 8px;
  color: #2b2118;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.78), transparent 24%),
    linear-gradient(135deg, rgba(255, 176, 46, 0.14), transparent 38%),
    #f4dfb5;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.38);
}

.beast-stage {
  min-height: 16rem;
  border: 2px solid rgba(76, 56, 36, 0.34);
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 62%, rgba(91, 147, 255, 0.20), transparent 36%),
    rgba(255, 253, 244, 0.72);
}

.beast-stage img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  image-rendering: auto;
  animation: beast-breathe 2.8s ease-in-out infinite, beast-sway 4.2s ease-in-out infinite;
  transform-origin: 50% 78%;
}

@keyframes beast-breathe {
  0%, 100% { scale: 1 1; }
  50% { scale: 1.035 0.985; }
}

@keyframes beast-sway {
  0%, 100% { rotate: -1deg; }
  50% { rotate: 1.6deg; }
}

.beast-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.element-chip {
  display: inline-flex;
  min-height: 1.8rem;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.72rem;
  color: #fff;
  background: #3566b0;
  font-weight: 900;
  font-size: 0.82rem;
}

.beast-info h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1.35;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.catchphrase {
  margin-top: 0.55rem;
  font-weight: 900;
  line-height: 1.6;
}

.flavor {
  margin-top: 0.65rem;
  white-space: pre-line;
  line-height: 1.7;
  font-size: 0.92rem;
}

.moves {
  display: grid;
  gap: 0.55rem;
}

.move {
  border: 1px solid rgba(243, 236, 221, 0.14);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  background: rgba(33, 28, 23, 0.82);
}

.move-head {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: space-between;
}

.move h3 {
  min-width: 0;
  color: var(--cream);
  font-size: 1rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.move-meta {
  flex: none;
  color: var(--bg);
  background: var(--green);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-weight: 900;
  font-size: 0.78rem;
}

.move p {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.stat {
  min-height: 4.3rem;
  border: 1px solid rgba(243, 236, 221, 0.14);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 0.55rem;
  background: rgba(20, 17, 14, 0.68);
}

.stat dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
}

.stat dd {
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.2;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: stretch;
  padding-bottom: 0.3rem;
}

.card-actions .tool-button,
.card-actions .steam-cta {
  min-width: min(100%, 10.5rem);
  text-align: center;
  justify-content: center;
}

.steam-cta {
  border-radius: 8px;
  padding: 0.72rem 1.2rem;
  font-size: 0.95rem;
}

.steam-cta[aria-disabled="true"] {
  opacity: 0.72;
  cursor: default;
}

.demo-entry {
  border-color: rgba(255, 176, 46, 0.65);
}

.generation-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: rgba(10, 8, 6, 0.9);
  backdrop-filter: blur(2px);
}

.generation-content {
  display: grid;
  justify-items: center;
  gap: 1.1rem;
  color: var(--cream);
  text-align: center;
}

#generationSilhouette {
  width: min(68vw, 19rem);
  height: min(68vw, 19rem);
  filter: drop-shadow(0 0 1.2rem rgba(255, 176, 46, 0.4));
  opacity: 0.88;
  transform-origin: 50% 72%;
  animation: generation-awaken 2.6s ease-in-out infinite;
}

.generation-content p {
  margin: 0;
  color: var(--cream);
  font-weight: 900;
  line-height: 1.7;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.name-dialog {
  position: fixed;
  inset: 0;
  z-index: 1003;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(10, 8, 6, 0.86);
  backdrop-filter: blur(2px);
}

.name-dialog-panel {
  width: min(100%, 28rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  color: var(--cream);
  background: rgba(33, 28, 23, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.46);
  animation: name-dialog-in 0.16s ease-out;
}

.name-dialog-panel h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.45;
  font-weight: 400;
  text-align: center;
}

.name-dialog-panel input {
  width: 100%;
  min-height: 3rem;
  border: 2px solid rgba(243, 236, 221, 0.44);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  color: #14110e;
  background: #fffdf4;
  font: inherit;
  font-weight: 800;
  text-align: center;
}

.name-dialog-panel input:focus {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.name-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.reveal-flash {
  position: fixed;
  inset: 0;
  z-index: 1001;
  pointer-events: none;
  background: #ffffff;
  opacity: 0;
}

.reveal-flash.is-active {
  animation: reveal-flash 0.42s ease-out;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 1002;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

@keyframes generation-awaken {
  0%, 100% {
    opacity: 0.58;
    transform: translate3d(-0.25rem, 0, 0) rotate(-1deg) scale(0.98, 1.02);
  }

  50% {
    opacity: 1;
    transform: translate3d(0.25rem, -0.25rem, 0) rotate(1.4deg) scale(1.03, 0.99);
  }
}

@keyframes reveal-flash {
  0% { opacity: 0; }
  24% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes name-dialog-in {
  0% {
    opacity: 0;
    transform: translateY(0.3rem) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 920px) {
  .demo-hero-grid,
  .demo-grid {
    grid-template-columns: 1fr;
  }

  .demo-copy h1 {
    font-size: 2.15rem;
  }

  .demo-status-card {
    transform: none;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .demo-hero {
    padding-top: 3rem;
  }

  .draw-panel {
    padding: 0.8rem;
  }

  .panel-head {
    align-items: stretch;
  }

  .swatches {
    grid-template-columns: repeat(9, minmax(1.8rem, 1fr));
  }

  .swatch {
    width: 100%;
    height: 2rem;
  }

  .tool-group {
    box-sizing: border-box;
    flex-wrap: wrap;
    max-width: 100%;
  }

  .tool-group .tool-button {
    flex: 0 0 auto;
  }

  .submit-area {
    grid-template-columns: 1fr;
  }

  .generate-button {
    width: 100%;
  }

  .demo-consent {
    font-size: 0.78rem;
  }

  .name-dialog-actions > * {
    width: 100%;
  }

  .card-paper {
    grid-template-columns: 1fr;
  }

  .card-actions > * {
    width: 100%;
  }

  .beast-stage {
    min-height: 13rem;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .beast-stage img,
  #generationSilhouette,
  .name-dialog-panel,
  .reveal-flash.is-active {
    animation: none;
  }
}

@media (pointer: coarse) {
  #drawCanvas {
    cursor: default;
  }

  #cursorCanvas {
    display: none;
  }
}
