body {
  font-family: "Inter", sans-serif;
  background-color: #f3f4f6;
  background: linear-gradient(
    to right,
    #f3f4f6 0%,
    #ede9fe 20%,
    #ede9fe 80%,
    #f3f4f6 100%
  );
}
.logo-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
}
.logo-link img {
  width: 6rem;
  height: 6rem;
  border-radius: 9999px;
  border: 2px solid #a855f7;
}

.roll-button {
  background-image: linear-gradient(to right, #a855f7, #ec4899);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1.75rem;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  width: 100%;
  text-align: center;
  display: block;
}
.roll-button:hover {
  background-image: linear-gradient(to right, #9333ea, #db2777);
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}
.roll-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 3D DICE & SHADOW STYLES */
.perspective-1000 {
  perspective: 1000px;
}
.dice-cube {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto;
  transform-style: preserve-3d;
  transition: transform 1.5s ease-out;
}

.dice-face {
  position: absolute;
  width: 96px;
  height: 96px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.9rem;
  font-weight: bold;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  background-color: #ffffff;
  backface-visibility: hidden;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.05);
  word-break: break-word;
  padding: 5px;
  line-height: 1.2;
  text-align: center;
}
.face-front {
  transform: rotateY(0deg) translateZ(48px);
}
.face-back {
  transform: rotateY(180deg) translateZ(48px);
}
.face-right {
  transform: rotateY(90deg) translateZ(48px);
}
.face-left {
  transform: rotateY(-90deg) translateZ(48px);
}
.face-top {
  transform: rotateX(90deg) translateZ(48px);
}
.face-bottom {
  transform: rotateX(-90deg) translateZ(48px);
}

.dice-cube.rolling {
  animation: roll-keyframes 1s linear infinite;
}
@keyframes roll-keyframes {
  0% {
    transform: rotateX(0) rotateY(0) rotateZ(0);
  }
  100% {
    transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg);
  }
}

/* Grounding Shadow */
.dice-shadow {
  width: 80px;
  height: 20px;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.2) 0%,
    rgba(0, 0, 0, 0) 70%
  );
  margin: -10px auto 1rem auto;
  border-radius: 50%;
  transition:
    transform 1.5s ease-out,
    opacity 1.5s;
  opacity: 1;
}
.dice-shadow.pulsing {
  animation: shadow-pulse 0.5s infinite alternate;
}
@keyframes shadow-pulse {
  from {
    transform: scale(0.6);
    opacity: 0.5;
  }
  to {
    transform: scale(0.8);
    opacity: 0.4;
  }
}

/* ACCORDION */
.config-section-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease-out;
  overflow: hidden;
}
.config-section-wrapper.open {
  grid-template-rows: 1fr;
}
.config-section-inner {
  min-height: 0;
  padding: 2px;
}

/* Color row container */
.color-input-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 520px;
  margin: 0.375rem auto;
  padding: 0 0.25rem;
}

.color-number {
  font-weight: bold;
  width: 1.5rem;
  text-align: right;
  flex: 0 0 auto;
}

input[type="color"].color-picker-input {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  padding: 0;
  cursor: pointer;
  appearance: none;
  background-color: transparent;
  flex: 0 0 auto;
}
input[type="color"].color-picker-input::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"].color-picker-input::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}
input[type="color"].color-picker-input::-moz-color-swatch-wrapper {
  padding: 0;
}
input[type="color"].color-picker-input::-moz-color-swatch {
  border: none;
  border-radius: 4px;
}

/* UPDATED INPUTS WRAP FOR TEXT FEATURE */
.inputs-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: wrap; /* Allow wrapping on small screens */
}

/* Advanced Mode Layout Reordering */
.inputs-wrap.advanced-on .name-input {
  order: 1;
}
.inputs-wrap.advanced-on .hex-input {
  order: 2;
}
.inputs-wrap.advanced-on .face-text-input {
  order: 3;
  flex: 1 1 100%; /* Forces it to a new line and fills the width */
}

.name-input {
  min-width: 0;
  flex: 1 1 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.face-text-input {
  min-width: 0;
  flex: 1 1 100px;
}

.hex-input {
  width: 10ch;
  max-width: 12ch;
  flex: 0 0 10ch;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.remove-btn {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border: none;
  border-radius: 50%;
  background-color: #fee2e2;
  color: #ef4444;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 0.25rem;
}
.remove-btn:hover {
  background-color: #fecaca;
  transform: scale(1.1);
}

.color-number,
.color-picker-input,
.remove-btn {
  flex-shrink: 0;
}
.advanced-hidden {
  display: none !important;
}

/* Preset Manager Styles */
.preset-container {
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.preset-select {
  flex-grow: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  background-color: white;
  min-width: 0;
}

.preset-btn {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #d1d5db;
  background: white;
  color: #4b5563;
}

.preset-btn.save:hover {
  background-color: #d1fae5;
  border-color: #34d399;
  color: #059669;
}
.preset-btn.delete:hover {
  background-color: #fee2e2;
  border-color: #f87171;
  color: #b91c1c;
}

#add-color-button {
  background-color: #6b7280;
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 9999px;
  font-weight: bold;
  transition: all 0.3s ease-in-out;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  width: 100%;
  margin-bottom: 1rem;
  font-size: 1rem;
}
#add-color-button:hover {
  background-color: #4b5563;
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}
#add-color-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.restore-button {
  background-color: #fc8181;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-weight: 600;
  transition: 0.2s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  width: 100%;
  text-align: center;
  display: block;
  margin-top: 1rem;
  font-size: 1rem;
}
.restore-button:hover {
  background-color: #f56565;
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}
.restore-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.action-prompts-button {
  background-color: #b182e3;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-weight: 600;
  transition: 0.2s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  width: 100%;
  text-align: center;
  display: block;
  margin-top: 0.75rem;
  font-size: 1rem;
  text-decoration: none;
}
.action-prompts-button:hover {
  background-color: #a46ede;
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

/* GLASSMORPHISM MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s,
    visibility 0.3s;
}
.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}
.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 0.75rem;
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 320px;
  width: 90%;
  transform: translateY(-20px);
  transition: transform 0.3s;
  position: relative;
}
.modal-overlay.show .modal-content {
  transform: translateY(0);
}
.modal-buttons {
  display: flex;
  justify-content: space-around;
  margin-top: 1.5rem;
}
.modal-button {
  padding: 0.75rem 1.25rem;
  border-radius: 9999px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}
.modal-button.confirm {
  background-color: #c53030;
  color: white;
}
.modal-button.save-confirm {
  background-color: #059669;
  color: white;
}
.modal-button.cancel {
  background-color: #e2e8f0;
  color: #4a5568;
}
.modal-button.info-ok {
  background-color: #a855f7;
  color: white;
}
.hidden-section {
  display: none;
}

.challenge-button {
  background-color: #ef4444;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1rem;
  width: 100%;
  display: block;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease-in-out;
}
.challenge-button:hover {
  background-color: #dc2626;
  transform: translateY(-2px);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: #a855f7;
}
input:focus + .slider {
  box-shadow: 0 0 1px #a855f7;
}
input:checked + .slider:before {
  transform: translateX(26px);
}

.description-link-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: -0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #6b46c1;
}
.description-link {
  display: inline-flex;
  align-items: center;
  text-align: center;
  color: #6b46c1;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s ease-in-out;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}
.description-link i {
  margin-right: 0.35rem;
}
.description-link:hover {
  color: #805ad5;
  text-decoration: underline;
}
.separator {
  display: inline-flex;
  align-items: center;
  margin: 0 0.45rem;
  color: #6b46c1;
  font-size: 1em;
  height: 1em;
  opacity: 0.5;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-weight: 600;
}

/* --- TOP LEFT BACK BUTTON --- */
.top-left-back-btn {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #e5e7eb;
  color: #6b7280;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border-radius: 9999px;
  transition: all 0.2s ease;
  font-family: "Inter", sans-serif;
  z-index: 50;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.top-left-back-btn:hover {
  background: #ffffff;
  color: #7c3aed; /* Purple-600 */
  border-color: #d8b4fe; /* Purple-300 */
  transform: translateX(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
  .top-left-back-btn {
    top: 1rem;
    left: 1rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 360px) {
  .color-input-group {
    flex-wrap: wrap;
    row-gap: 0.35rem;
  }
  .color-number {
    width: 1.25rem;
    order: 0;
  }
  .color-picker-input {
    order: 1;
  }
  .remove-btn {
    order: 2;
    margin-left: auto;
  }
  .inputs-wrap {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
  }
  .name-input,
  .face-text-input {
    flex: 1 1 auto;
    max-width: 100%;
  }
  .hex-input {
    flex: 0 0 10ch;
    width: 10ch;
    max-width: 12ch;
  }
}

#qr-modal-content {
  max-width: 350px;
  padding: 1.5rem;
  position: relative;
}
#qr-modal-content img {
  width: 100%;
  height: auto;
  max-width: 250px;
  margin: 0 auto 1rem auto;
  display: block;
  border-radius: 0.5rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.qr-modal-close-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #4a5568;
  line-height: 1;
  padding: 0.25rem;
  border-radius: 50%;
  transition:
    background-color 0.2s,
    color 0.2s;
}

.bottom-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #4b5563;
  background: #f3f4f6;
  border: 1px dashed #d1d5db;
  border-radius: 9999px;
  padding: 0.5rem 0.875rem;
  font-size: 0.9rem;
  margin-top: 0.75rem;
  user-select: none;
}

/* --- PRO & FACILITATOR LOCK STYLES --- */
.locked-feature {
  opacity: 0.5;
  pointer-events: none;
  filter: grayscale(1);
  position: relative;
  cursor: not-allowed;
}

.lock-wrapper {
  display: inline-block;
  position: relative;
  cursor: pointer;
  width: 100%;
}

.preset-container .lock-wrapper {
  width: auto; /* keep icon buttons tight */
}

.lock-wrapper::after {
  content: "\f023";
  font-family:
    "Font Awesome 6 Free", "Font Awesome 5 Free", "FontAwesome";
  font-weight: 900;
  position: absolute;
  top: 6px;
  right: -8px;
  background: #fbbf24;
  color: white;
  width: 21px;
  height: 21px;
  font-size: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  z-index: 50;
  transition: transform 0.2s;
}
.lock-wrapper:hover::after {
  transform: scale(1.1);
}

/* Ensures all preset buttons look identical when the group is locked */
.locked-feature .preset-btn {
  color: #9ca3af !important; /* Forces uniform light gray icon */
  border-color: #e5e7eb !important; /* Forces uniform light gray border */
  opacity: 1 !important; /* Prevents the delete button from double-dimming */
}

/* Restores the pressed-down click animation for the Challenge button */
.challenge-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Restores the pressed-down click animation for the Action Prompts button */
.action-prompts-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Restores the pressed-down click animation for the Floating Back button */
.floating-back-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Centers the lock icon over the grouped buttons */
.group-lock::after {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}
.group-lock:hover::after {
  transform: translateX(-50%) scale(1.1);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield; /* Firefox */
  appearance: textfield;
}

/* --- Onboarding Spotlight Overlay --- */
#spotlight-tour-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 4000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  cursor: pointer;
}

#spotlight-tour-overlay.show {
  opacity: 1;
  visibility: visible;
}

#tour-close-hint {
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.tour-highlight {
  position: relative !important;
  z-index: 4001 !important;
  background-color: white; 
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.4), 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
  border-radius: 0.5rem;
  transition: box-shadow 0.3s ease;
}

/* Fix for the Dice Roller's specific layout */
.preset-container.tour-highlight {
  background-color: white !important; /* Ensure it overrides the gray background when highlighted */
}

/* --- Fix for stacking context trapping the tour highlight --- */
body.tour-active .max-w-md.transition-transform {
  transform: none !important;
  z-index: auto !important;
  transition: none !important;
  animation: none !important;
}