/* Themed scrollbars — Firefox + WebKit (Chrome, Safari, Edge, Opera, Electron) */
html {
  scrollbar-width: thin;
  scrollbar-color: #5a6eb8 #120d1f;
}
::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-track {
  background: #141020;
  border-left: 1px solid #2a2440;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4a5cb8, #303b95);
  border: 1px solid #6f8eff;
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #5d6fd0, #3d4ca3);
}
::-webkit-scrollbar-corner {
  background: #141020;
}

body { margin: 0; font-family: "Comic Neue", system-ui, sans-serif; background: #100A16; color: #F4F1FF; position: relative; overflow-x: hidden; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 18%, rgba(252,219,46,.10), transparent 25%),
    radial-gradient(circle at 80% 30%, rgba(61,247,236,.08), transparent 28%),
    radial-gradient(circle at 70% 78%, rgba(244,54,160,.08), transparent 24%);
  animation: arcadeGlow 8s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: -2;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.02) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
  pointer-events: none;
  z-index: -1;
}
.wrap { max-width: 1140px; margin: 0 auto; padding: 16px; }
.top { position: sticky; top: 0; z-index: 400; backdrop-filter: blur(6px); background: #0F0915; border-bottom: 2px solid #303B95; }
.top-inner { display: flex; align-items: center; justify-content: flex-start; gap: 12px; }
.drawer-menu-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #6f8eff;
  border-radius: 0;
  background: linear-gradient(180deg, #4153ab, #303b95);
  color: #eef4ff;
  cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.drawer-menu-btn:hover { filter: brightness(1.1); }
.drawer-menu-btn .material-symbols-outlined { font-size: 24px; }
.tutorial-menu-btn {
  border-color: #7fd6ff;
  background: linear-gradient(180deg, #2f3d68, #25304f);
}
.logo-tools { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.logo-tools label { margin-top: 0; }
.logo-ai-btn { align-self: flex-start; margin-top: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.top-inner .brand { flex: 1; min-width: 0; }
.brand-logo-wrap {
  flex-shrink: 0;
}
.brand-logo-link {
  display: block;
  line-height: 0;
  text-decoration: none;
  border-radius: 8px;
  outline-offset: 3px;
}
.brand-logo-link:focus-visible {
  outline: 2px solid #7fd6ff;
}
.brand-logo-link:hover .brand-logo {
  filter: brightness(1.08);
  box-shadow: 0 0 12px rgba(252, 219, 46, 0.35);
}
.brand-logo { width: 42px; height: 42px; border-radius: 8px; border: 2px solid #FCDB2E; object-fit: cover; image-rendering: pixelated; display: block; transition: filter 0.15s ease, box-shadow 0.15s ease; }
.brand-text { min-width: 0; }
.brand-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.brand-badge {
  flex-shrink: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 0.4rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
  padding: 5px 7px;
  color: #100A16;
  background: linear-gradient(180deg, #FCDB2E, #F9A529);
  border: 1px solid #303B95;
  box-shadow: 0 1px 0 rgba(0,0,0,.35);
  white-space: nowrap;
}
.brand h1 { margin: 0; font-family: "Press Start 2P", monospace; font-size: 1rem; color: #FCDB2E; text-shadow: 0 0 8px rgba(252,219,46,.35); }
.brand-slogan {
  margin: 4px 0 0;
  min-height: 0;
  max-width: 22rem;
  color: #7fd6ff;
  font-size: 0.88rem;
  line-height: 1.35;
  transition: opacity 0.28s ease;
}
.brand-slogan.is-fading {
  opacity: 0;
}

/* Quest stage titles */
.wizard-stage-title {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 14px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 2px solid #4a4577;
  background: linear-gradient(145deg, rgba(48, 59, 149, 0.4), rgba(18, 14, 32, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 4px 18px rgba(0, 0, 0, 0.25);
}
.wizard-stage-title__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: rgba(0, 0, 0, 0.28);
  border: 2px solid #6f8eff;
  color: #fcdb2e;
}
.wizard-stage-title__icon .material-symbols-outlined {
  font-size: 26px;
}
.wizard-stage-title__main {
  flex: 1 1 12rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wizard-stage-title__quest {
  font-family: "Press Start 2P", monospace;
  font-size: 0.48rem;
  letter-spacing: 0.08em;
  color: #9ec8ff;
  text-transform: uppercase;
  line-height: 1.5;
}
.wizard-stage-title__topic {
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  font-weight: 700;
  color: #f4f1ff;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-shadow: 0 0 14px rgba(127, 214, 255, 0.12);
}
.wizard-stage-title__help {
  flex-shrink: 0;
  margin-left: auto;
  padding-top: 2px;
}
@media (max-width: 520px) {
  .wizard-stage-title__help {
    margin-left: 0;
  }
}

.app { display: grid; grid-template-columns: 1fr; gap: 16px; }

.panel {
  background: linear-gradient(180deg, #251a3c, #1a1429);
  border: 2px solid #4d4278;
  border-radius: 0;
  box-shadow: 0 0 0 2px #120d1f, 0 12px 24px rgba(0,0,0,.35);
  padding: 16px;
  min-width: 0;
}
.side { height: fit-content; transition: all .25s ease; }

.hint { color: #d1ccde; font-size: 0.95rem; }
.line { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.line.compact { margin-top: 6px; flex-wrap: nowrap; }

.btn {
  border: 2px solid #6f86ff;
  border-radius: 0;
  padding: 10px 14px;
  background: linear-gradient(180deg, #4153ab, #303b95);
  color: #eef4ff;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.25);
  transition: transform .08s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.secondary { border-color: #7FD6FF; background: linear-gradient(180deg, #2f3d68, #25304f); color: #d7ecff; }
.btn.danger { border-color: #f06ab5; background: linear-gradient(180deg, #5d2a4f, #46203c); color: #ffd9ef; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-summon-btn {
  background: rgb(252, 219, 46);
  border-color: rgb(252, 219, 46);
  color: #241a00;
}
.ai-summon-btn:hover { filter: brightness(1.03); }

input, textarea, select {
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  border: 2px solid #4e4679;
  border-radius: 0;
  padding: 10px;
  font-family: inherit;
  color: #F5F2FF;
  background: #191327;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #7FD6FF; border-color: #7FD6FF; }
label { display: block; font-weight: 700; margin-top: 10px; }

.wizard-shell {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 0;
  align-items: stretch;
  min-width: 0;
}

/* Slide-in drawer (projects + API) — retro purple rail colours */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: rgba(8, 4, 18, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.drawer-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.app-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 360;
  width: min(320px, 92vw);
  max-width: 100%;
  height: 100%;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #303b95, #2a3179);
  border-right: 2px solid #6f8eff;
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.5);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.app-drawer__main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-drawer.is-open {
  transform: translateX(0);
}
.app-drawer__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 10px;
  border-bottom: 2px dashed rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.2);
}
.app-drawer__title {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
  color: #fcdb2e;
  text-shadow: 0 0 8px rgba(252, 219, 46, 0.35);
  line-height: 1.5;
}
.drawer-close-btn {
  width: 36px;
  height: 36px;
  padding: 0;
}
.app-drawer__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 12px 12px 12px;
  scrollbar-width: thin;
  scrollbar-color: #9eb4f0 rgba(0, 0, 0, 0.4);
}
.app-drawer__scroll::-webkit-scrollbar {
  width: 10px;
}
.app-drawer__scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.35);
  border-left: 1px solid rgba(111, 142, 255, 0.4);
}
.app-drawer__scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #7a90e0, #3d4ca3);
  border: 1px solid rgba(200, 215, 255, 0.35);
}
.app-drawer__scroll::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #92a4f0, #4d5cb8);
}
.app-drawer__scroll > .drawer-menu + .drawer-menu {
  margin-top: 12px;
}
/* Drawer accordion menus */
.drawer-menu {
  border: 2px dashed rgba(255, 255, 255, 0.22);
  background: rgba(10, 14, 35, 0.45);
  overflow: visible;
}
.drawer-menu[open] {
  background: rgba(8, 10, 28, 0.55);
}
.drawer-menu__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-weight: 700;
  font-size: 0.88rem;
  color: #e8eeff;
  line-height: 1.3;
}
.drawer-menu__summary::-webkit-details-marker {
  display: none;
}
.drawer-menu__summary-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.drawer-menu__icon {
  font-size: 20px;
  color: #7fd6ff;
  flex-shrink: 0;
}
.drawer-menu__label {
  flex: 1;
  min-width: 0;
}
.drawer-menu__chevron {
  flex-shrink: 0;
  font-size: 22px;
  color: #9ec8ff;
  transition: transform 0.22s ease;
}
.drawer-menu[open] .drawer-menu__chevron {
  transform: rotate(180deg);
  color: #fcdb2e;
}
.drawer-menu__body {
  padding: 10px 12px 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.18);
  animation: drawerMenuOpen 0.2s ease;
}
@keyframes drawerMenuOpen {
  from {
    opacity: 0.85;
  }
  to {
    opacity: 1;
  }
}
.drawer-menu__hint {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: #c8c0e0;
  line-height: 1.45;
}
.drawer-menu__row .btn {
  font-size: 0.82rem;
  padding: 8px 10px;
}
.app-drawer input,
.app-drawer select {
  background: rgba(10, 14, 35, 0.65);
  border-color: #4e4679;
}
body.drawer-open {
  overflow: hidden;
}

.wizard-steps-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 14px 12px;
  background: linear-gradient(180deg, #303b95, #2a3179);
  border-right: 2px dashed rgba(255, 255, 255, 0.22);
  border-bottom: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  align-self: stretch;
  min-height: 0;
}
.wizard-steps-row .step {
  color: #d4dcff;
  width: 100%;
  min-width: 0;
}
.wizard-steps-row .step.active {
  color: #ffffff;
}
.wizard-steps-row .step.completed {
  color: #b8c8f0;
}
.wizard-main {
  background: #1a1429;
  border: 2px solid #4d4278;
  border-radius: 0;
  padding: 0;
  padding-bottom: 14px;
  min-width: 0;
  overflow-x: clip;
}
.wizard-main > .stage,
.wizard-main > .nav {
  padding-left: 14px;
  padding-right: 14px;
}
.wizard-main > .stage {
  padding-top: 14px;
}
.wizard-main > .nav {
  padding-top: 16px;
  margin-top: 0;
}
.ai-settings {
  margin-top: 14px;
}
.ai-oracle-form {
  margin: 0;
  padding: 0;
  border: 0;
}
.ai-settings summary {
  cursor: pointer;
  font-weight: 700;
  color: #7fd6ff;
}
.ai-provider-help {
  margin-top: 10px;
}
.ai-provider-help .hint {
  margin: 0.5rem 0;
}
.ai-provider-help code {
  font-size: 0.85em;
  color: #fcdb2e;
}
.ai-cors-hint {
  border-left: 3px solid #f9a529;
  padding-left: 10px;
}
.ai-key-row label,
.ai-custom-row label {
  display: block;
  margin-top: 8px;
}
.step {
  border: 0;
  background: transparent;
  color: #d4dcff;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 4px 6px;
}
.step-bullet {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  aspect-ratio: 1 / 1;
  border: 2px solid #7a90e0;
  background: #24306a;
  color: #e8eeff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.25);
}
.step-copy { display: flex; flex-direction: column; gap: 2px; }
.step-copy small { font-size: .62rem; opacity: .8; letter-spacing: .8px; }
.step-copy strong { font-size: .73rem; letter-spacing: .8px; }
.step.active { color: #ffffff; }
.step.active .step-bullet { border-color: #8af9f0; background: #3d4ca3; box-shadow: 0 0 10px rgba(61,247,236,.35); }
.step.completed .step-bullet { border-color: #3df7ec; background: #21566f; color: #d8fffb; }

.stage { display: none; }
.stage.active { display: block; animation: fade .22s ease-in; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks label { margin-top: 0; font-weight: 700; }
.field-row { display: grid; grid-template-columns: 1fr 1fr .7fr 1fr auto; gap: 8px; margin: 8px 0; }
.field-row button { padding: 8px 10px; }
pre#output {
  background: #121827;
  color: #d9e8ff;
  border: 2px solid #34446f;
  border-radius: 0;
  padding: 12px;
  min-height: 120px;
  max-height: min(50vh, 380px);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  font-size: 0.78rem;
  line-height: 1.4;
  tab-size: 2;
}
.nav { justify-content: space-between; margin-top: 16px; }
.logo-preview { display: none; margin-top: 10px; max-width: 180px; border: 2px solid #4A4577; background: #0E0A16; image-rendering: pixelated; }
.logo-preview.show { display: block; }
.advanced { margin-top: 12px; border: 2px dashed #4A4577; border-radius: 0; padding: 10px; background: #1A1429; }
.advanced summary { cursor: pointer; color: #7FD6FF; font-weight: 700; }
.docs { margin-top: 14px; border-top: 2px solid #4A4577; padding-top: 10px; }
.helper {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 0; background: #2B355E; color: #FCDB2E; font-size: 12px; margin-left: 6px;
  cursor: help; position: relative; border: 1px solid #4F5A90;
}
.helper::after {
  content: attr(data-tip); position: absolute; left: 50%; transform: translateX(-50%); bottom: 130%;
  min-width: 180px; max-width: 240px; background: #222036; color: #F4F1FF; border: 1px solid #7FD6FF;
  padding: 8px; font-size: 12px; line-height: 1.3; opacity: 0; pointer-events: none; transition: opacity .2s;
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}
.helper:hover::after { opacity: 1; }
.helper--wide::after {
  min-width: 220px;
  max-width: min(92vw, 440px);
  white-space: normal;
}
/* Quest 1 — conjure field (wizard glow) */
.wizard-conjure-label {
  margin-top: 12px;
}
.wizard-conjure-input {
  margin-top: 6px;
  border: 2px solid #5a6eb8;
  background: linear-gradient(180deg, #1a1530, #191327);
  animation: wizardConjureGlow 2.8s ease-in-out infinite;
}
.wizard-conjure-input::placeholder {
  color: #9a92b8;
}
.wizard-conjure-input:hover {
  border-color: #8ec8ff;
}
.wizard-conjure-input:focus {
  animation: none;
  border-color: #fcdb2e;
  outline: none;
  box-shadow:
    0 0 16px rgba(252, 219, 46, 0.35),
    0 0 32px rgba(127, 214, 255, 0.35),
    inset 0 0 24px rgba(252, 219, 46, 0.08);
}
@keyframes wizardConjureGlow {
  0%,
  100% {
    border-color: #5a6eb8;
    box-shadow:
      0 0 14px rgba(127, 214, 255, 0.22),
      0 0 28px rgba(61, 247, 236, 0.12),
      inset 0 0 18px rgba(127, 214, 255, 0.06);
  }
  50% {
    border-color: #7fd6ff;
    box-shadow:
      0 0 26px rgba(127, 214, 255, 0.5),
      0 0 44px rgba(252, 219, 46, 0.14),
      inset 0 0 22px rgba(127, 214, 255, 0.12);
  }
}
.source-spellbook-layout {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr;
  gap: 12px;
  margin-top: 10px;
  align-items: start;
}
@media (max-width: 720px) {
  .source-spellbook-layout {
    grid-template-columns: 1fr;
  }
}
.source-spellbook-tree {
  list-style: none;
  margin: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(50vh, 360px);
  overflow: auto;
  border: 2px solid #4a4577;
  background: #141020;
}
.source-spellbook-file {
  width: 100%;
  text-align: left;
  font-size: 0.78rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  padding: 6px 8px;
  border: 1px solid #4a4577;
  background: #1a1429;
  color: #d4dcff;
  cursor: pointer;
  border-radius: 0;
}
.source-spellbook-file:hover {
  border-color: #7fd6ff;
  color: #fff;
}
.source-spellbook-file.is-active {
  border-color: #fcdb2e;
  background: #2a2450;
  color: #fcdb2e;
}
.source-spellbook-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.source-spellbook-path {
  display: block;
  font-size: 0.8rem;
  word-break: break-all;
  color: #7fd6ff;
  flex: 1;
  min-width: 0;
}
.source-spellbook-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.source-spellbook-actions .btn {
  font-size: 0.76rem;
  padding: 6px 10px;
}
.source-spellbook-pane {
  min-width: 0;
}
.source-spellbook-code-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  border: 2px solid #4a4577;
  background: #0a0812;
  max-height: min(55vh, 520px);
  overflow: hidden;
}
.source-spellbook-gutter {
  margin: 0;
  padding: 10px 8px 10px 10px;
  overflow: auto;
  overflow-x: hidden;
  text-align: right;
  color: #5c5478;
  user-select: none;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  tab-size: 2;
  border: 0;
  border-right: 1px solid #2a2440;
  background: #0e0c14;
  min-width: 2.75rem;
  box-sizing: border-box;
}
.source-spellbook-editor {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  min-height: 200px;
  max-height: min(55vh, 520px);
  resize: none;
  overflow: auto;
  tab-size: 2;
  border: 0 !important;
  margin: 0;
  border-radius: 0;
  background: #12101c;
  color: #e8e4ff;
}
.source-spellbook-editor:focus {
  outline: 2px solid rgba(127, 214, 255, 0.35);
  outline-offset: -2px;
}

.switch-wrap { display: inline-flex; align-items: center; gap: 8px; }
.switch-wrap input { display: none; }
.switch { width: 44px; height: 24px; background: #3A355B; border: 1px solid #5A538A; position: relative; transition: all .2s; }
.switch::after { content: ""; width: 18px; height: 18px; background: #ffffff; position: absolute; left: 2px; top: 2px; transition: transform .2s; }
.switch-wrap input:checked + .switch { background: #303B95; border-color: #303B95; }
.switch-wrap input:checked + .switch::after { transform: translateX(20px); background: #3DF7EC; }

.foundation { margin-top: 14px; border-top: 2px solid #4a4577; padding-top: 10px; text-align: center; }
.foundation--drawer {
  flex-shrink: 0;
  margin-top: 0;
  padding: 12px 12px max(14px, env(safe-area-inset-bottom, 0px));
  border-top: 2px dashed rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.28);
  text-align: center;
}
.foundation img { max-width: 115px; opacity: .95; filter: invert(1) hue-rotate(180deg) contrast(1.1); }
.footer { margin-top: 0px; text-align: center; color: #CDC7DE; padding: 0px; margin-top: 0px; margin-bottom: 0px; }
.footer a, a { color: #7FD6FF; }
.footer a:hover, a:hover { color: #3DF7EC; }
.material-symbols-outlined { font-size: 19px; vertical-align: middle; }
.icon-btn {
  border-radius: 0;
  border: 2px solid #6f8eff;
  background: linear-gradient(180deg, #37458f, #2c3570);
  color: #d8e4ff;
  cursor: pointer;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { filter: brightness(1.08); }
.top-toggle { border-color: #7fd6ff; }

@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }
@keyframes arcadeGlow { from { transform: scale(1); } to { transform: scale(1.05) translateY(-1%); } }
@keyframes factoryMove { from { transform: translateX(0); } to { transform: translateX(40px); } }
@keyframes wandSpin { from { transform: rotate(-14deg) scale(1); } to { transform: rotate(16deg) scale(1.1); } }
@keyframes sparklePulse { 0% { opacity: .2; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.25); } 100% { opacity: .2; transform: scale(.8); } }
@keyframes spellAuroraShift {
  0% { opacity: 0.45; transform: translate(-8%, -4%) rotate(0deg) scale(1); }
  50% { opacity: 0.75; transform: translate(6%, 8%) rotate(180deg) scale(1.08); }
  100% { opacity: 0.45; transform: translate(-8%, -4%) rotate(360deg) scale(1); }
}
@keyframes spellMoteDrift {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  12% { opacity: 0.9; }
  88% { opacity: 0.85; }
  100% { transform: translate(var(--mx, 40px), var(--my, -120px)) scale(1.1); opacity: 0; }
}
@keyframes runeTwinkle {
  0%, 100% { opacity: 0.25; transform: translateY(0) scale(0.9); }
  40% { opacity: 1; transform: translateY(-3px) scale(1.15); }
  60% { opacity: 0.6; transform: translateY(1px) scale(1); }
}
@keyframes spellBoxPulse {
  0%, 100% { box-shadow: 0 0 0 2px #120d1f, 0 12px 30px rgba(0,0,0,.45), 0 0 24px rgba(127,214,255,.12); }
  50% { box-shadow: 0 0 0 2px #fcdb2e33, 0 14px 36px rgba(0,0,0,.5), 0 0 40px rgba(252,219,46,.18); }
}

/* [hidden] must win: a plain `display: grid` here overrides the UA [hidden] rule. */
.spell-overlay[hidden] {
  display: none !important;
}
.spell-overlay:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.spell-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(9, 6, 16, 0.78);
  backdrop-filter: blur(2px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.spell-overlay::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.tutorial-overlay[hidden] {
  display: none !important;
}
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 980;
  display: grid;
  place-items: center;
  background: rgba(9, 6, 16, 0.82);
  padding: clamp(14px, 5vw, 24px);
}
.tutorial-card {
  box-sizing: border-box;
  width: min(640px, calc(100vw - clamp(28px, 9vw, 64px)));
  max-width: calc(100vw - clamp(28px, 9vw, 64px));
  border: 2px solid #7fd6ff;
  background: linear-gradient(165deg, #2a1f45 0%, #191129 45%, #120d22 100%);
  box-shadow: 0 0 0 2px #120d1f, 0 12px 34px rgba(0, 0, 0, 0.55);
  padding: clamp(10px, 2.8vw, 14px);
}
.tutorial-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tutorial-card__head h2 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 0.72rem;
  line-height: 1.5;
  color: #fcdb2e;
}
.tutorial-step-counter {
  margin: 10px 0 4px;
  color: #9ec8ff;
  font-size: 0.82rem;
  font-weight: 700;
}
.tutorial-step-title {
  margin: 0;
  color: #f4f1ff;
  font-size: 1.02rem;
}
.tutorial-step-body {
  margin: 10px 0 0;
  color: #d6d0e7;
  line-height: 1.45;
}
.tutorial-card__actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tutorial-card__foot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #4a4577;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tutorial-dismiss-toggle {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d6d0e7;
  font-weight: 700;
}
.tutorial-dismiss-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
}
@media (max-width: 640px) {
  .tutorial-overlay {
    padding: 18px;
  }
  .tutorial-card {
    width: min(400px, calc(100vw - 44px));
    max-width: min(400px, calc(100vw - 44px));
  }
  .tutorial-card__head h2 {
    font-size: 0.58rem;
  }
  .tutorial-step-title {
    font-size: 0.95rem;
  }
  .tutorial-step-body {
    font-size: 0.9rem;
  }
}
@media (max-width: 420px) {
  .tutorial-overlay {
    padding: 16px;
  }
  .tutorial-card {
    width: calc(100vw - 34px);
    max-width: calc(100vw - 34px);
  }
}
.spell-box {
  position: relative;
  width: min(480px, 100%);
  max-width: min(480px, calc(100vw - 24px));
  overflow: hidden;
  margin: auto;
  box-sizing: border-box;
  border: 2px solid #7FD6FF;
  background: linear-gradient(165deg, #2a1f45 0%, #191129 45%, #120d22 100%);
  box-shadow: 0 0 0 2px #120d1f, 0 12px 30px rgba(0,0,0,.45);
  padding: 14px 16px 16px;
  text-align: center;
  animation: spellBoxPulse 3.2s ease-in-out infinite;
}
.spell-aurora {
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(252, 219, 46, 0.14), transparent 55%),
    radial-gradient(ellipse 70% 50% at 70% 80%, rgba(61, 247, 236, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(244, 54, 160, 0.08), transparent 60%);
  pointer-events: none;
  animation: spellAuroraShift 14s linear infinite;
  z-index: 0;
}
.spell-motes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}
.spell-motes span {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fcdb2e;
  box-shadow: 0 0 8px #fcdb2e;
  left: calc(8% + var(--i, 0) * 11%);
  bottom: 12%;
  animation: spellMoteDrift 4.5s ease-in-out infinite;
  opacity: 0;
}
.spell-motes span:nth-child(1) { --i: 0; --mx: 30px; --my: -140px; animation-delay: 0s; animation-duration: 4.2s; background: #3df7ec; box-shadow: 0 0 8px #3df7ec; }
.spell-motes span:nth-child(2) { --i: 1; --mx: -50px; --my: -160px; animation-delay: 0.6s; animation-duration: 5.1s; }
.spell-motes span:nth-child(3) { --i: 2; --mx: 70px; --my: -100px; animation-delay: 1.1s; animation-duration: 3.8s; background: #f436a0; box-shadow: 0 0 8px #f436a0; }
.spell-motes span:nth-child(4) { --i: 3; --mx: -20px; --my: -180px; animation-delay: 0.3s; animation-duration: 4.9s; }
.spell-motes span:nth-child(5) { --i: 4; --mx: 55px; --my: -130px; animation-delay: 1.8s; animation-duration: 5.4s; }
.spell-motes span:nth-child(6) { --i: 5; --mx: -65px; --my: -95px; animation-delay: 2.2s; animation-duration: 4.4s; background: #7fd6ff; box-shadow: 0 0 8px #7fd6ff; }
.spell-motes span:nth-child(7) { --i: 6; --mx: 40px; --my: -170px; animation-delay: 0.9s; animation-duration: 5.8s; }
.spell-motes span:nth-child(8) { --i: 7; --mx: -35px; --my: -115px; animation-delay: 2.6s; animation-duration: 4.1s; }
.spell-glyph {
  position: relative;
  z-index: 2;
  width: min(92px, 22vw);
  height: min(92px, 22vw);
  min-width: 56px;
  min-height: 56px;
  margin: 4px auto 10px;
  border: 2px solid #4d4278;
  background: rgba(48, 59, 149, 0.35);
  border-radius: 4px;
  box-shadow: inset 0 0 20px rgba(252, 219, 46, 0.06);
}
.spell-glyph .wand {
  font-size: min(48px, 11vw);
  color: #FCDB2E;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 6px rgba(252, 219, 46, 0.5));
  animation: wandSpin 650ms ease-in-out infinite alternate;
}
.spell-glyph .spark {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3DF7EC;
  box-shadow: 0 0 10px rgba(61,247,236,.8);
  animation: sparklePulse 900ms ease-in-out infinite;
}
.spell-glyph .spark.one { left: 14px; top: 14px; }
.spell-glyph .spark.two { right: 12px; top: 26px; animation-delay: 200ms; background: #F436A0; box-shadow: 0 0 10px rgba(244,54,160,.8); }
.spell-glyph .spark.three { left: 38px; bottom: 10px; animation-delay: 360ms; background: #FCDB2E; box-shadow: 0 0 10px rgba(252,219,46,.8); }
.spell-glyph .spark.four { right: 22px; bottom: 18px; animation-delay: 520ms; background: #7fd6ff; box-shadow: 0 0 10px rgba(127,214,255,.75); }

.spell-primary {
  position: relative;
  z-index: 2;
  margin: 4px 0 0;
  color: #EDE8FF;
  font-weight: 700;
  font-size: clamp(0.88rem, 3.5vw, 1.05rem);
  line-height: 1.38;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-family: "Comic Neue", system-ui, sans-serif;
}
.spell-flair {
  position: relative;
  z-index: 2;
  margin: 10px 0 0;
  min-height: 2.6em;
  color: #b8a8e8;
  font-size: clamp(0.78rem, 3vw, 0.92rem);
  line-height: 1.4;
  font-style: italic;
  font-family: "Comic Neue", system-ui, sans-serif;
}
.spell-runes {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  margin: 12px 0 10px;
  font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  color: #7fd6ff;
  text-shadow: 0 0 10px rgba(127, 214, 255, 0.35);
}
.spell-runes .rune {
  display: inline-block;
  animation: runeTwinkle 2.4s ease-in-out infinite;
}
.spell-runes .rune:nth-child(1) { animation-delay: 0s; }
.spell-runes .rune:nth-child(2) { animation-delay: 0.25s; }
.spell-runes .rune:nth-child(3) { animation-delay: 0.5s; }
.spell-runes .rune:nth-child(4) { animation-delay: 0.15s; }
.spell-runes .rune:nth-child(5) { animation-delay: 0.4s; }
.spell-runes .rune:nth-child(6) { animation-delay: 0.65s; }
.spell-runes .rune:nth-child(7) { animation-delay: 0.3s; }
.spell-runes .rune:nth-child(8) { animation-delay: 0.55s; }

/* In-app toasts (replaces window.alert) */
.wizard-toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(120%);
  width: min(420px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 2px solid #4e4679;
  background: linear-gradient(145deg, #2a1f45, #1a1428);
  box-shadow:
    0 0 0 1px rgba(252, 219, 46, 0.12),
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 32px rgba(127, 214, 255, 0.08);
  color: #ede8ff;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.32s ease;
}
.wizard-toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.wizard-toast[data-variant="info"] {
  border-color: #7fd6ff;
}
.wizard-toast[data-variant="warning"] {
  border-color: #f9a529;
  box-shadow:
    0 0 0 1px rgba(249, 165, 41, 0.25),
    0 12px 40px rgba(0, 0, 0, 0.55);
}
.wizard-toast[data-variant="error"] {
  border-color: #f436a0;
  box-shadow:
    0 0 0 1px rgba(244, 54, 160, 0.22),
    0 12px 40px rgba(0, 0, 0, 0.55);
}
.wizard-toast-icon {
  flex-shrink: 0;
  font-size: 26px;
  color: #fcdb2e;
  margin-top: 2px;
}
.wizard-toast[data-variant="warning"] .wizard-toast-icon {
  color: #f9a529;
}
.wizard-toast[data-variant="error"] .wizard-toast-icon {
  color: #f436a0;
}
.wizard-toast-text {
  flex: 1;
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  font-family: "Comic Neue", system-ui, sans-serif;
  font-weight: 600;
  min-width: 0;
}
.wizard-toast-action {
  flex-shrink: 0;
  padding: 8px 10px;
  font-size: 0.78rem;
}
.wizard-toast-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid #4e4679;
  border-radius: 8px;
  background: rgba(48, 59, 149, 0.35);
  color: #b8a8e8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.wizard-toast-close:hover {
  background: rgba(252, 219, 46, 0.12);
  border-color: #fcdb2e;
  color: #fcdb2e;
}
.wizard-toast-close .material-symbols-outlined {
  font-size: 22px;
}

@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .wizard-shell {
    grid-template-columns: 1fr;
  }
  .wizard-steps-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    padding: 12px 12px 14px;
    border-right: none;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.22);
  }
  .wizard-steps-row .step {
    flex: 1 1 120px;
    width: auto;
  }
  .wizard-main {
    padding-bottom: 12px;
  }
  .wizard-main > .stage,
  .wizard-main > .nav {
    padding-left: 12px;
    padding-right: 12px;
  }
  pre#output {
    max-height: min(40vh, 260px);
    font-size: 0.68rem;
    padding: 10px;
  }
  .grid2 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .step { min-width: 0; }
  .step::after { display: none; }
}
