* {
  position: relative;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  background-color: #000;
}

body {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.5);
  font-family: "Russo One", arial, sans-serif;
  line-height: 1.25;
  letter-spacing: 0.06em;
}

.hide {
  opacity: 0;
  visibility: hidden;
}

.remove {
  display: none !important;
}

.blur {
  filter: blur(12px);
}

.container {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Splash screen */
.loading-init.splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 9999;
  /* ensure overlay is above everything while visible */
  will-change: opacity, transform;
  transition: opacity 0.36s ease;
}
.loading-init.splash.splash--hide {
  opacity: 0;
  pointer-events: none;
}
.splash__logo {
  width: min(56vw, 520px);
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.7));
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
  transform-origin: center center;
  transform: scale(0.98);
  opacity: 0.0;
  transition: transform 360ms cubic-bezier(.2,.9,.2,1), opacity 360ms ease;
}
/* pop animation trigger when app is ready to show splash effect */
.loading-init.splash.splash--pop .splash__logo {
  transform: scale(1);
  opacity: 1;
}
/* when hiding, shrink a bit for nicer transition */
.loading-init.splash.splash--hide .splash__logo {
  transform: scale(0.92);
  opacity: 0;
}

.stage-container {
  overflow: hidden;
  box-sizing: initial;
  border: 1px solid #222;
  margin: -1px;
}
@media (max-width: 840px) {
  .stage-container {
    border: none;
    margin: 0;
  }
}

.canvas-container {
  width: 100%;
  height: 100%;
  transition: filter 0.3s;
}
.canvas-container canvas {
  position: absolute;
  mix-blend-mode: lighten;
  transform: translateZ(0);
}

.controls {
  position: absolute;
  top: 0px;
  width: 100%;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  transition: opacity 0.3s, visibility 0.3s;
}
@media (min-width: 840px) {
  .controls {
    visibility: visible;
  }
  /* Allow hover to reveal controls normally, but allow overriding via .no-hover when we need to keep them hidden (e.g. Settings open) */
  .controls.hide:hover {
    opacity: 1;
  }
  /* When .no-hover is present, suppress the hover reveal to keep controls hidden even if .hide is applied */
  .controls.no-hover.hide:hover {
    opacity: 0 !important;
    pointer-events: none;
  }
}

.menu {
  /* Full-height right-side panel like Manage for consistent UX */
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: min(520px, 92vw);
  background: rgba(0,0,0,0.94);
  border-left: 1px solid rgba(255,255,255,0.04);
  box-shadow: -8px 0 24px rgba(0,0,0,0.6);
  z-index: 50;
  transition: transform 0.28s ease, opacity 0.28s;
  transform: translateX(100%);
  opacity: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.menu.hide {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}
.menu:not(.hide) {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* Inner content mirrors Manage panel spacing and column layout */
.menu__inner-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  height: 100%;
  box-sizing: border-box;
}

/* Header styling aligned with Manage */
.menu__header {
  font-size: 1.1rem;
  text-transform: uppercase;
  color: rgba(255,255,255,0.9);
  margin: 0;
  padding: 6px 0 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  user-select: none;
  width: fit-content;
  height: 50px;
  align-items: center;
  display: flex;
}

/* Optional subheader small text */
.menu__subheader {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  padding: 8px 0;
}

/* Form should fill available column space like Manage editor */
.menu form {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  -webkit-overflow-scrolling: touch;
}

/* Form options use same label widths and input sizes as Manage editor */
.menu .form-option {
  display: flex;
  align-items: center;
  margin: 12px 0;
  transition: opacity 0.18s;
}
.menu .form-option label {
  display: block;
  min-width: 150px;
  width: 150px;
  padding-right: 12px;
  text-align: right;
  text-transform: uppercase;
  color: rgba(255,255,255,0.9);
  font-size: 0.85rem;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

/* Inputs mirror Manage editor controls */
.menu .form-option--select select,
.menu .form-option input[type="text"],
.menu .form-option input[type="number"] {
  flex: 1;
  height: 36px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.9);
  padding: 6px 8px;
  border-radius: 4px;
  font-family: "Russo One", arial, sans-serif;
}
.menu .form-option--select select option,
.selector option {
  background-color: black;
}

/* Checkbox alignment consistent with editor */
.menu .form-option--checkbox input {
  display: block;
  width: 26px;
  height: 26px;
  margin: 0;
  opacity: 0.85;
}

/* Small-screen adjustments */
@media (max-width: 840px) {
  .menu {
    width: 100%;
    right: 0;
    border-left: none;
    box-shadow: none;
  }
  .menu .form-option select,
  .menu .form-option input {
    outline: none;
  }
  .manage-form__row span {
    text-align: right;
  }
  .manage-page__body {
    padding: 0px 10px 4px !important;
  }
  #newShellBtn {
    width: 50px;
    height: 50px;
  }
}

.close-menu-btn {
  position: absolute;
  top: 15px;
  right: 15px;
}

.top-btn {
  font-size: 20px;
  cursor: pointer;
}

/* Selected saved-firework button and popover */
.selected-btn {
  position: relative;
}
.selected-popover {
  position: absolute;
  top: 34px;
  right: 0px;
  min-width: 180px;
  background: rgba(20,15,19,0.96);
  border: 1px solid rgba(255,255,255,0.06);
  color: #ffbff6;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
  z-index: 60;
  display: none;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}
.selected-popover.visible {
  display: block;
}
.selected-popover .sel-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  flex: 1;
  padding-right: 8px;
}
.selected-popover .sel-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.selected-popover .sel-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.04);
}

.top-btn:hover {
  color: #ffc2f3;
}

.btn {
  width: 50px;
  height: 50px;
  display: grid;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  cursor: pointer;
  transition: opacity 0.3s;
  font-size: 20px;
  align-content: center;
  background-color: #140f13;
  border: none;
  border-radius: 10px;
  color: #ffbff6;
  border: 2px solid rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 138, 239, 0.18);
  text-align: center;
}
.btn svg {
  display: block;
  margin: auto;
}

.credits {
  margin-top: auto;
  margin-bottom: 0px;
  padding-top: 6px;
  font-size: 0.8em;
  opacity: 0.75;
  user-select: none;
}
.credits a {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
}
.credits a:hover, .credits a:active {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: underline;
}



/* Manage page (standalone view) */
.manage-page {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  background: linear-gradient(180deg, rgba(6,6,6,0.98), rgba(12,12,12,0.98));
  z-index: 40;
}
.manage-page__inner {
  /* Fill the entire viewport so Manage becomes a true standalone full-page view */
  width: 100%;
  height: 100%;
  margin: 0;
  border: none;
  background: rgba(0,0,0,0.92);
  display: flex;
  flex-direction: column;
  border-radius: 0;
  overflow: hidden;
}
.manage-page__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  user-select: none;
}
.manage-page__header h2 {
  margin: 0;
  color: rgba(255,255,255,0.9);
  font-size: 1.2rem;
  text-transform: uppercase;
}
.manage-page__body {
  padding: 0px 24px 4px 24px;
  flex: 1;
  display: flex;
  /* Stretch children vertically so the manage view fills full height */
  align-items: stretch;
  justify-content: center;
}

/* Manage split layout: list + editor */
.manage-page__body {
  display: flex;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}
.manage-list {
  /* Make the list take full width so Manage is only the list by default */
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.03);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Editor hidden by default; toggled via .manage-page.editing */
.manage-editor {
  display: none;
  width: 100%;
}

/* When editing, show the editor and hide the list */
.manage-page.editing .manage-list {
  display: none;
}
.manage-page.editing .manage-editor {
  display: block;
  overflow-y: auto;
}
.manage-list header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.manage-list h3 {
  margin: 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  color: rgba(255,255,255,0.9);
  text-align: center;
}
.manage-list__meta {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.65);
  position: absolute;
  right: 0px;
  top: 0px;
  user-select: none;
}
.manage-list__items {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  max-height: 80%;
}
.manage-list__items .saved-item {
  padding: 8px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.02);
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  user-select: none;
  /* ensure items don't force the list to grow horizontally */
  min-width: 0;
  overflow: hidden;
}

/* Make the left/title area shrinkable so long names truncate instead of forcing horizontal scroll */
.manage-list__items .saved-item > div:first-child,
.manage-list__items .saved-item .manage-list__name {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

/* Keep action buttons at fixed size and prevent them from shrinking */
.saved-item .item-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Tabs in manage list header */
.manage-list__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 8px;
}
.manage-list__left {
  width: fit-content; /* room for the New button */
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  z-index: 999;
}
.manage-list__center {
  flex: 1;
  text-align: center;
  position: absolute;
  width: 100%;
  top: 5px;
  user-select: none;
}
.manage-list__right {
  width: 80px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.manage-list__tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.tab-btn {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.85);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}
.tab-btn.active {
  background: rgba(75, 51, 72, 0.18);
  border-color: rgba(255,138,239,0.18);
  color: #ffbff6;
}
.manage-list__items .saved-item.selected {
  outline: 2px solid rgba(255, 138, 239, 0.18);
  background: #140f13;
}
.manage-list__name {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* hide legacy meta label and replace with action buttons */
.manage-list__meta-small {
  display: none;
}

/* Action buttons for saved items */
.saved-item .item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.saved-item .item-actions button {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.85);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  min-width: 56px;
}
.saved-item .item-actions button:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.98);
}
.manage-list__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Manage form styles (editor) */
.manage-form {
  width: 100%;
  display: grid;
  gap: 10px;
  color: rgba(255,255,255,0.9);
}
.manage-editor {
  background: rgba(255,255,255,0.02);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.02);
}
.manage-form__row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  user-select: none;
}
.manage-form__row label {
  min-width: 150px;
  font-size: 0.85rem;
  text-transform: uppercase;
  opacity: 0.85;
}
.manage-form__row input[type="text"],
.manage-form__row input[type="number"],
.manage-form__row select {
  flex: 1;
  height: 36px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.95);
  padding: 6px 8px;
  border-radius: 4px;
}
.manage-form__row input[type="range"] {
  flex: 1;
}
.manage-form__row .inline-color {
  width: 40px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
}
.color-row { align-items: center; }
.effects-row .effects-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.effects-list label {
  background: rgba(255,255,255,0.04);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}
.manage-form__actions {
  display: block;
  margin-top: 8px;
}
.manage-form__actions button {
  display: inline;
}
.manage-form__notice {
  margin-top: 8px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
}

.btn-right {
  float: right;
  display: flex;gap: 10px;float: right;
}

#newShellBtn {
  z-index: 99999;
}

/* Mobile create menu: hidden on desktop, bottom sheet look on mobile */
.mobile-create-menu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  display: none;
  justify-content: center;
  pointer-events: none;
}
.mobile-create-menu .mobile-create-menu__inner {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,10,0.98);
  border-top: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 -8px 28px rgba(0,0,0,0.6);
  box-sizing: border-box;
  pointer-events: auto;
}
.mobile-create-menu .mobile-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  min-width: 42%;
  height: 64px;
  border-radius: 10px;
  font-size: 0.95rem;
  justify-content: center;
}
.mobile-create-menu .mobile-option span {
  display: block;
  font-size: 0.85rem;
  text-transform: none;
  color: #ffbff6;
}
.mobile-create-menu .mobile-close {
  position: absolute;
  right: 12px;
  top: -50px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

/* Mobile per-item actions menu (bottom sheet) */
.mobile-item-menu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 130;
  display: none;
  justify-content: center;
  pointer-events: none;
}
.mobile-item-menu .mobile-item-menu__inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  background: rgba(10,10,10,0.98);
  border-top: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 -8px 28px rgba(0,0,0,0.6);
  box-sizing: border-box;
  pointer-events: auto;
}
.mobile-item-action {
  justify-content: flex-start;
  gap: 10px;
  padding: 14px 16px;
  height: 56px;
  border-radius: 10px;
  font-size: 1rem;
  text-transform: none;
  color: #ffbff6;
  width: 100% !important;
}
.mobile-item-action i {
  width: 22px;
  text-align: center;
  margin-right: 6px;
}
.mobile-item-close {
  position: absolute;
  right: 12px;
  top: -60px;
  width: 44px !important;
  height: 44px !important;
  border-radius: 10px;
}
.mobile-item-menu.visible {
  display: flex;
  animation: slideUp 220ms cubic-bezier(.2,.9,.2,1);
}

/* On small screens hide the inline import button and rely on the plus + bottom menu */
@media (max-width: 840px) {
  #importShellBtn {
    display: none;
  }
  /* mobile menu visible via toggled .visible (JS controls) */
  .mobile-create-menu.visible {
    display: flex;
    animation: slideUp 220ms cubic-bezier(.2,.9,.2,1);
  }
  @keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
}

/* Hide Edit, Duplicate, and Delete buttons for built-in items shown in the Default tab.
   The action button order is: Launch, Edit, Duplicate, Export, Delete. We hide 2,3 and 5. */
.manage-list__items.default .saved-item .item-actions button:nth-child(2),
.manage-list__items.default .saved-item .item-actions button:nth-child(3),
.manage-list__items.default .saved-item .item-actions button:nth-child(5) {
  display: none;
}

.sel-swatch {
  background-clip: content-box;
}

/* Mobile improvements for Manage editor: make editor full-width, inputs and buttons touch-friendly,
   increase spacing, and ensure the editor fits nicely without horizontal scrolling. */
@media (max-width: 840px) {
  /* Show the editor as a full-page panel when editing on mobile */
  .manage-page.editing {
    /* Keep manage page layout but ensure editor fills available space */
  }
  .manage-page.editing .manage-list {
    display: none;
  }
  .manage-page.editing .manage-editor {
    display: block;
    width: 100%;
    padding: 16px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Make editor visually stand out on mobile */
    border-radius: 0;
    border: none;
    background: rgba(0,0,0,0.96);
    padding-right: 18px;
    /* Reserve space at bottom for pinned action bar */
    /* padding-bottom: 110px; */
    height: calc(100% - 80px);
  }

  /* Hide the top manage header when editor is open on mobile to maximize space */
  .manage-page.editing .manage-page__header {
    display: none;
  }

  /* Pin form actions outside of scrollable area at bottom of viewport */
  .manage-form__actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.60);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
  }
  /* Ensure the buttons inside the pinned actions are sized appropriately */
  .manage-form__actions .btn {
    width: 64px;
    height: 64px;
  }

  /* Increase tappable targets inside editor */
  .manage-form__row {
    min-height: 64px;
    gap: 14px;
    padding: 6px 0;
  }

  /* Stack label above input/control for each row and make controls full width */
  .manage-form__row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px !important;
    margin-bottom: 8px;
  }
  .manage-form__row label {
    width: 100%;
    font-size: 0.95rem;
    text-align: left;
  }
  .manage-form__row input[type="text"],
  .manage-form__row input[type="number"],
  .manage-form__row select,
  .menu .form-option--select select,
  .menu .form-option input[type="text"],
  .menu .form-option input[type="number"] {
    height: 48px;
    font-size: 1rem;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
  }
  .manage-form__row input[type="range"] {
    height: 40px;
    width: 100%;
  }

  /* Ensure inline color inputs also respect the stacked layout */
  .manage-form__row .inline-color {
    width: 48px;
    height: 36px;
    margin-left: 0;
  }

  /* Make effects list wrap nicely when stacked */
  .effects-row .effects-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Larger inline color input for easier tapping (already set, keep) */
  .manage-form__row .inline-color {
    width: 48px;
    height: 36px;
  }

  /* Make primary action buttons easier to tap */
  .btn, .btn-right .btn {
    width: 64px;
    height: 64px;
    font-size: 22px;
    border-radius: 12px;
  }
  .btn-right {
    gap: 12px;
  }

  /* Ensure list items inside Manage list stay scrollable and reachable when shown */
  .manage-list__items {
    max-height: calc(100vh - 220px);
    -webkit-overflow-scrolling: touch;
  }

  /* Slightly bigger saved-item touch target */
  .manage-list__items .saved-item {
    padding: 12px;
    min-height: 56px;
  }

  /* Improve spacing for effects checkboxes and color rows on mobile */
  .effects-row .effects-list {
    gap: 10px;
  }
  .effects-list label {
    padding: 10px 12px;
    font-size: 0.95rem;
  }

  /* Make the editor header/back button easier to hit */
  .manage-page__header {
    padding: 12px 14px;
  }

  /* Avoid horizontal scroll */
  .manage-page__inner, .manage-page__body, .manage-list, .manage-editor {
    min-width: 0;
    overflow-x: hidden;
  }
}

/* Very small screens: hide custom item names to prevent layout overflow while keeping presets visible */
@media (max-width: 260px) {
  .manage-list__items.custom .manage-list__name {
    display: none;
  }
}

/* Under 300px: hide centered manage header and make New button slightly smaller for tight layouts */
@media (max-width: 300px) {
  .manage-list__center {
    display: none;
  }
  #newShellBtn {
    height: 40px;
    width: 40px;
    margin-bottom: 10px;
  }
}