body {
  font-family: 'Arial', sans-serif;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  /* Techno / cyber default background: dark blues with neon glow */
  background:
    radial-gradient(circle at top, #0b3b8c 0, #050816 45%, #02030a 100%);
  background-color: #050816;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  transition:
    background 0.6s ease,
    background-color 0.6s ease,
    color 0.3s ease;
}

/* when chat/talk is focused, lock main page scroll but keep inner panels scrollable */
body.scroll-locked {
  overflow: hidden;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  background: rgba(4, 10, 30, 0.96);
  color: #e0f7ff;
  padding: 30px;
  border-radius: 18px;
  box-shadow:
    0 0 24px rgba(0, 255, 255, 0.25),
    0 12px 28px rgba(0, 0, 0, 0.8);
}

h1 {
  text-align: center;
  color: #64ffda;
  margin-bottom: 30px;
  text-shadow: 0 0 14px rgba(0, 255, 255, 0.5);
}

/* Techno (default) mode: 3D, bobbing title */
body:not(.dark):not(.chocolate):not(.mint):not(.evil):not(.vanilla) h1 {
  position: relative;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow:
    0 0 14px rgba(0, 255, 255, 0.6),
    0 3px 0 rgba(0, 50, 80, 0.9),
    0 6px 0 rgba(0, 30, 60, 0.7),
    0 9px 18px rgba(0, 0, 0, 0.9);
  transform-origin: center bottom;
  /* bob + continuous glitch (color-shift & shake) */
  animation:
    techno-title-bob 2.6s ease-in-out infinite,
    techno-title-glitch 7s linear infinite;
}

/* trailing afterimages for techno title */
body:not(.dark):not(.chocolate):not(.mint):not(.evil):not(.vanilla) h1::before,
body:not(.dark):not(.chocolate):not(.mint):not(.evil):not(.vanilla) h1::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.28;
  text-shadow: none;
}

body:not(.dark):not(.chocolate):not(.mint):not(.evil) h1::before {
  color: rgba(0, 255, 255, 0.5);
  filter: blur(1px);
  transform-origin: center bottom;
  animation: techno-title-afterimage-1 2.6s ease-in-out infinite;
}

body:not(.dark):not(.chocolate):not(.mint):not(.evil) h1::after {
  color: rgba(0, 180, 255, 0.4);
  filter: blur(2px);
  transform-origin: center bottom;
  animation: techno-title-afterimage-2 2.6s ease-in-out infinite;
}

@keyframes techno-title-bob {
  0%   { transform: translateY(0) translateZ(0); }
  25%  { transform: translateY(-10px) translateZ(0); }
  50%  { transform: translateY(0) translateZ(0); }
  75%  { transform: translateY(7px) translateZ(0); }
  100% { transform: translateY(0) translateZ(0); }
}

/* trailing afterimage animations (slightly lag the main bob) */
@keyframes techno-title-afterimage-1 {
  0%   { transform: translateY(2px); }
  25%  { transform: translateY(-2px); }
  50%  { transform: translateY(1px); }
  75%  { transform: translateY(3px); }
  100% { transform: translateY(2px); }
}

@keyframes techno-title-afterimage-2 {
  0%   { transform: translateY(3px); }
  25%  { transform: translateY(-1px); }
  50%  { transform: translateY(2px); }
  75%  { transform: translateY(4px); }
  100% { transform: translateY(3px); }
}

/* brief glitch every ~7 seconds */
@keyframes techno-title-glitch {
  /* Only tweak color/glow so we don't override the bobbing transform */
  0%, 88% {
    filter: none;
  }
  89% {
    filter: hue-rotate(10deg) saturate(1.2);
  }
  90% {
    filter: hue-rotate(-10deg) saturate(1.3);
  }
  91% {
    filter: hue-rotate(15deg) saturate(1.4);
  }
  92% {
    filter: none;
  }
  93%, 100% {
    filter: none;
  }
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 30px;
}

input, textarea, select {
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

/* gentle focus / hover animation for slice‑of‑life feel */
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #ff80ab;
  box-shadow: 0 0 0 3px rgba(255, 128, 171, 0.25);
  background-color: #fff9fb;
}

select:hover, input:hover, textarea:hover {
  transform: translateY(-1px);
}

/* keep themed overrides compatible */
body.dark input, body.dark textarea, body.dark select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

body.dark input:focus, body.dark textarea:focus, body.dark select:focus {
  border-color: #81c784;
  box-shadow: 0 0 0 3px rgba(129, 199, 132, 0.5);
  background-color: #111a13;
}

body.chocolate input:focus, body.chocolate textarea:focus, body.chocolate select:focus {
  border-color: #ffb74d;
  box-shadow: 0 0 0 3px rgba(255, 183, 77, 0.4);
  background-color: #4a2d25;
}

body.mint input:focus, body.mint textarea:focus, body.mint select:focus {
  border-color: #26a69a;
  box-shadow: 0 0 0 3px rgba(38, 166, 154, 0.35);
  background-color: #e8fffb;
}

body.evil input:focus, body.evil textarea:focus, body.evil select:focus {
  border-color: #e53935;
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.45);
  background-color: #25060a;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

button {
  background: #0d47a1;
  color: #e0f7ff;
  padding: 15px;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.12s ease, box-shadow 0.12s ease;
  transform-origin: center;
}

/* cozy hover / press micro‑animations */
button:hover {
  background: #1565c0;
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(0, 191, 255, 0.5);
}

button:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* make key buttons a tiny bit bouncy on hover */
#generateBtn:hover,
#themeToggle:hover,
#cookieGachaBtn:hover {
  animation: button-wiggle 220ms ease-out;
}

/* simple wiggle keyframe for "slice of life" feel */
@keyframes button-wiggle {
  0% { transform: translateY(-1px) rotate(0deg); }
  35% { transform: translateY(-2px) rotate(-0.8deg); }
  70% { transform: translateY(-1px) rotate(0.6deg); }
  100% { transform: translateY(-1px) rotate(0deg); }
}

/* Make the Generate Cookie button pink */
#generateBtn {
  background: #00e5ff;
}

#generateBtn:hover {
  background: #00b0ff;
}

button:hover {
  background: #ff7043;
}

.result-section {
  text-align: center;
}

#cookieImage {
  max-width: 400px;
  border-radius: 10px;
  margin: 20px 0;
}

.hidden {
  display: none;
}

#cookieInfo {
  background: #f5f5f5;
  padding: 20px;
  border-radius: 8px;
  margin-top: 20px;
  text-align: left;
  line-height: 1.6;
}

#cookieInfo h3 {
  color: #d81b60;
  margin-top: 20px;
  margin-bottom: 10px;
}

#cookieInfo p {
  margin-bottom: 15px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3e5f5;
  border-top: 5px solid #d81b60;
  border-radius: 50%;
  /* Force the spinner to rotate smoothly even if other styles try to override animation */
  animation-name: spin, pulse;
  animation-duration: 1s, 2s;
  animation-timing-function: linear, ease-in-out;
  animation-iteration-count: infinite, infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.saved-cookies {
  margin-top: 30px;
  border-top: 2px solid #e0e0e0;
  padding-top: 20px;
}

.saved-cookies h2 {
  color: #d81b60;
  margin-bottom: 15px;
}

.cookie-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
}

.saved-cookie-card {
  background: #f8f8f8;
  border-radius: 8px;
  padding: 15px;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
  user-select: none; /* Prevent text selection when clicking */
}

.saved-cookie-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.saved-cookie-card h4 {
  color: #d81b60;
  margin: 0 0 10px 0;
}

.cookie-meta {
  font-size: 0.9em;
  color: #666;
}

.cookie-meta .add-to-saved {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-top: 5px;
}

.cookie-meta .add-to-saved:hover {
  background: #45a049;
}

.cookie-meta .delete-cookie {
  background: #ff4444;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-top: 5px;
  margin-left: 5px;
}

.cookie-meta .delete-cookie:hover {
  background: #cc0000;
}

.cookie-meta .skin-count {
  display: inline-block;
  background: #9c27b0;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  margin-left: 5px;
}

.delete-cookie {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.delete-cookie:hover {
  background: #cc0000;
}

.save-button {
  background: #42a5f5;
  margin-top: 15px;
}

.save-button:hover {
  background: #1e88e5;
}

.try-again-button {
  background: #ff9800;
  margin-top: 15px;
}

.try-again-button:hover {
  background: #fb8c00;
}

.button-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 15px;
}

.share-button {
  background: #2196F3;
  margin-top: 15px;
}

.share-button:hover {
  background: #1976D2;
}

.cookie-interaction-section {
  margin-top: 30px;
  padding: 20px;
  background: #f8f8f8;
  border-radius: 8px;
}

/* Battle Lab styles */
.battle-lab {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px dashed #e0e0e0;
}

.battle-lab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}

.battle-lab-field {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#battleNotes {
  width: 100%;
  min-height: 80px;
  margin-top: 8px;
}

#generateArenaBattleBtn {
  margin-top: 10px;
  background: #8e24aa;
}

#generateArenaBattleBtn:hover {
  background: #6a1b9a;
}

#arenaBattleResult {
  margin-top: 16px;
  padding: 16px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.cookie-interaction-section h3 {
  color: #6d4c41;
  margin-bottom: 10px;
}

.cookie-interaction-section .instruction {
  color: #666;
  font-size: 0.9em;
  margin-bottom: 15px;
}

#interactionContext {
  width: 100%;
  margin: 15px 0;
}

.cookie-selection-counter {
  font-size: 0.9em;
  color: #666;
  margin: 10px 0;
  font-style: italic;
}

.cookie-interaction-section #generateInteractionBtn {
  background: #9c27b0;
  opacity: 0.5;
  cursor: not-allowed;
}

.cookie-interaction-section #generateInteractionBtn:not([disabled]) {
  opacity: 1;
  cursor: pointer;
}

.cookie-interaction-section #generateInteractionBtn:not([disabled]):hover {
  background: #7b1fa2;
}

.saved-cookie-card.selected {
  background: #fce4ec;
  border: 2px solid #d81b60;
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(216, 27, 96, 0.2);
}

#interactionResult {
  margin-top: 20px;
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Red Velvet (evil) mode: highlight all relationship text in a dark red-brown instead of bright glow */
body.evil #interactionResult {
  background: rgba(60, 10, 10, 0.6);
  border: 1px solid rgba(120, 40, 40, 0.9);
}

/* Make sure ALL relationship text (including generated dialogues) is dark red-brown without glow,
   and apply the same styling to the main cookie generator output as well */
body.evil #interactionResult,
body.evil #interactionResult h3,
body.evil #interactionResult h4,
body.evil #interactionResult p,
body.evil #interactionResult li,
body.evil #interactionResult .guest-dialogues,
body.evil #interactionResult .dialogue-block,
body.evil #cookieInfo,
body.evil #cookieInfo h3,
body.evil #cookieInfo h4,
body.evil #cookieInfo p,
body.evil #cookieInfo li,
body.evil #cookieInfo .guest-dialogues,
body.evil #cookieInfo .dialogue-block {
  color: #ffb3b3 !important;
  text-shadow: none;
}

#fightResult {
  margin-top: 20px;
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.community-cookies {
  margin-top: 30px;
  border-top: 2px solid #e0e0e0;
  padding-top: 20px;
}

.community-cookies h2 {
  color: #d81b60;
  margin-bottom: 15px;
}

#communitySearch + .sort-toggle,
#communityWorldSearch + .sort-toggle {
  margin-left: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

/* Dark mode tweak for sort button */
body.dark .sort-toggle {
  background:#2a2a2f;
  color:#ddd;
}

.cookie-interaction-area {
  margin-top: 30px;
  border-top: 2px solid #e0e0e0;
  padding-top: 20px;
}

.cookie-interaction-area h2 {
  color: #d81b60;
  margin-bottom: 15px;
}

.view-cookie-card {
  background: #f8f8f8;
  border-radius: 8px;
  padding: 15px;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
}

.view-cookie-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.view-cookie-card h4 {
  color: #c62828;
  margin: 0 0 10px 0;
}

.view-controls {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}

.view-controls button {
  font-size: 12px;
  padding: 5px 10px;
}

.view-button {
  background: #42a5f5;
}

.share-to-community {
  background: #9c27b0;
}

.shared-by {
  font-size: 0.8em;
  color: #666;
  margin: 3px 0;
  font-style: italic;
}

.skins-container {
  margin-top: 20px;
  border-top: 2px solid #e0e0e0;
  padding-top: 15px;
}

.skin-entry {
  background: #fff;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  border-left: 4px solid #6d4c41;
}

.skin-entry h4 {
  color: #c62828;
  margin: 0 0 10px 0;
  font-size: 1.1em;
}

.skin-entry p {
  margin: 0;
  line-height: 1.5;
  color: #333;
}

.characteristics-group {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

.characteristics-group select {
  flex: 1;
}

#cookieGender,
#cookieAge {
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
}

#cookieAppearance,
#cookieLore,
#cookiePersonality {
  min-height: 80px;
}

/* Magic Candy option */
.magic-candy-row {
  margin-top: 10px;
  padding: 10px;
  background: #fff3f8;
  border-radius: 8px;
  border: 1px dashed #ff80ab;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.magic-candy-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9em;
}

.magic-candy-toggle strong {
  color: #d81b60;
}

#magicCandyNotes {
  min-height: 70px;
  font-size: 0.9em;
}

body.dark .magic-candy-row {
  background: #10231a;
  border-color: #81c784;
}

.gender-group {
  flex: 1;
  display: flex;
  gap: 10px;
}

#customGender {
  flex: 1;
}

.chat-section {
  margin-top: 30px;
  border-top: 2px solid #e0e0e0;
  padding-top: 20px;
}

.chat-messages {
  max-height: 300px;
  height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: #f8f8f8;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;

  /* mini-scrollbar like the main game */
  scrollbar-width: thin;           /* Firefox */
  scrollbar-color: #ff80ab #f8f8f8;
}

/* WebKit browsers */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #f8f8f8;
  border-radius: 8px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #ff80ab;
  border-radius: 8px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #f06292;
}

.chat-message {
  margin-bottom: 10px;
  padding: 8px 12px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.chat-message.new-message {
  animation: chat-slide-in 160ms ease-out;
}

@keyframes chat-slide-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.chat-message.own-message {
  background: #fce4ec;
  margin-left: 20px;
}

.chat-message .username {
  color: #d81b60;
  font-weight: bold;
  margin-right: 8px;
}

.chat-message .timestamp {
  color: #666;
  font-size: 0.8em;
  margin-left: 8px;
}

.chat-input-area {
  display: flex;
  gap: 10px;
  align-items: center;
}

#chatInput {
  flex: 1;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
}

#sendChat {
  padding: 12px 24px;
  background: #d81b60;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
}

.chat-image-attach {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f0f0f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.chat-image-attach input[type="file"] {
  display: none;
}

.chat-image-preview {
  max-width: 56px;
  max-height: 56px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #ff80ab;
  background: #fff;
  position: relative;
}

.chat-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-image-preview::after {
  content: "×";
  position: absolute;
  top: -10px;
  right: -6px;
  background: #ff5252;
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* Inline chat images */
.chat-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 10px;
  margin-top: 6px;
  display: block;
}

body.dark .chat-image-attach {
  background:#2a2a2f;
  color:#eee;
}

body.dark .chat-image-preview {
  background:#1b1b20;
  border-color:#81c784;
}

#sendChat:hover {
  background: #c2185b;
}

.chat-message .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.reference-cookies-section {
  margin: 15px 0;
  padding: 15px;
  background: #f8f8f8;
  border-radius: 8px;
}

/* Dark & chocolate theme backgrounds for inspiration selector */
body.dark .reference-cookies-section {
  background: #000000;
}

body.chocolate .reference-cookies-section {
  background: #4e342e;
}

.reference-cookies-section label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.reference-cookies-section .instruction {
  color: #666;
  font-size: 0.9em;
  margin: 10px 0;
}

.reference-cookie-card {
  background: white;
  border-radius: 8px;
  padding: 15px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
}

.reference-cookie-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.reference-cookie-card.selected {
  background: #fce4ec;
  border-color: #d81b60;
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(216, 27, 96, 0.2);
}

#referenceList {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 10px;
}

/* World maker layout */
.world-maker-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.world-meta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.world-meta-row select {
  flex: 1;
  min-width: 160px;
}

.world-stage-count {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.world-side-stories {
  font-size: 0.85em;
  color: #eee;
}

.world-cookie-selectors {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

@media (min-width: 720px) {
  .world-cookie-selectors {
    flex-direction: row;
  }
}

.world-cookie-column {
  flex: 1;
  min-width: 0;
}

.world-cookie-list .saved-cookie-card {
  cursor: pointer;
}

.world-cookie-card.selected,
.world-placeholder-card.selected {
  background: #fce4ec;
  border: 2px solid #d81b60;
  box-shadow: 0 4px 8px rgba(216,27,96,0.2);
}

.world-result {
  margin-top: 16px;
  padding: 16px;
  border-radius: 10px;
  background: #f8f8f8;
  max-height: 360px;
  overflow-y: auto;
}

/* View Cutscenes button */
.view-cutscenes-button {
  margin-top: 10px;
  background: #9c27b0;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.view-cutscenes-button:hover {
  background: #7b1fa2;
}
body.dark .view-cutscenes-button {
  background: #66bb6a;
}

/* Cutscene modal */
.cutscene-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2100;
}
.cutscene-modal.hidden {
  display: none;
}
.cutscene-modal-content {
  background: #fff;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
.cutscene-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cutscene-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #c62828;
}
.cutscene-close {
  background: transparent;
  color: #555;
  padding: 4px 8px;
  border-radius: 50%;
  font-size: 16px;
}
.cutscene-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  font-size: 0.95rem;
}
.cutscene-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 8px;
}
.cutscene-controls button {
  flex: 1;
  padding: 8px 10px;
  font-size: 14px;
}
.cutscene-counter {
  font-size: 0.85rem;
  color: #555;
  min-width: 80px;
  text-align: center;
}

body.dark .cutscene-modal-content {
  background: #141417;
  color: #eaeaea;
}
body.dark .cutscene-modal-header h3 {
  color: #b3ffb3;
}
body.dark .cutscene-close {
  color: #ddd;
}
body.dark .cutscene-counter {
  color: #aaa;
}

/* World stage rendering */
.world-stage {
  margin-bottom: 14px;
  padding: 10px 12px;
  background: #ffffff;
  border-radius: 8px;
  border-left: 3px solid #6d4c41;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.world-stage h4 {
  margin: 0 0 4px 0;
  color: #6d4c41;
  font-size: 0.98rem;
}

.world-stage p {
  margin: 2px 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

.world-stage .stage-cutscene {
  font-style: italic;
  color: #6a1b9a;
}

.world-stage .stage-lore {
  font-style: italic;
  color: #2e7d32;
}

body.dark .world-result {
  background: #1b1b20;
}

.world-result h3 {
  color: #6d4c41;
}

/* Saved worlds list */
#savedWorldList .saved-cookie-card h4 {
  margin-bottom: 4px;
}

#savedWorldList .world-meta {
  font-size: 0.85em;
  color: #666;
}

body.dark #savedWorldList .world-meta {
  color: #aaa;
}

/* Add rarity-based styling */
.skin-entry[data-rarity="Common"] {
  border-left: 4px solid #999999;
}

.skin-entry[data-rarity="Rare"] {
  border-left: 4px solid #4CAF50;
}

.skin-entry[data-rarity="Epic"] {
  border-left: 4px solid #9c27b0;
}

.skin-entry[data-rarity="Legendary"] {
  border-left: 4px solid #FFD700;
  background: linear-gradient(to right, rgba(255,215,0,0.1), transparent);
}

/* Witch – rarest tier above Beast */
.skin-entry[data-rarity="Witch"] {
  border-left: 4px solid #ff80ff;
  background: linear-gradient(to right, rgba(255,128,255,0.15), transparent);
}

.skin-rarity {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  margin-left: 8px;
  color: white;
}

.skin-entry[data-rarity="Common"] .skin-rarity {
  background: #999999;
}

.skin-entry[data-rarity="Rare"] .skin-rarity {
  background: #4CAF50;
}

.skin-entry[data-rarity="Epic"] .skin-rarity {
  background: #9c27b0;
}

.skin-entry[data-rarity="Legendary"] .skin-rarity {
  background: linear-gradient(45deg, #FFD700, #FFA500);
}

.skin-entry[data-rarity="Witch"] .skin-rarity {
  background: linear-gradient(45deg, #ff80ff, #e040fb);
}

.skin-gacha-animation {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #ccc;
  font-style: italic;
  color: #666;
}

.alignment-kingdom-group {
  display: flex;
  gap: 15px;
  margin: 10px 0;
}

.alignment-kingdom-group select {
  flex: 1;
}

.kingdom-group {
  flex: 1;
  display: flex;
  gap: 10px;
}

#customKingdom {
  flex: 1;
}

.voice-lines-section {
  background: #f8f8f8;
  border-radius: 8px;
  padding: 15px;
  margin: 15px 0;
}

.voice-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  padding: 10px;
  background: white;
  border-radius: 8px;
  border-left: 3px solid #6d4c41;
}

.play-voice {
  background: #ff8a65;
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.play-voice:hover {
  background: #ad1f1f;
}

.play-voice:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.voice-line-text {
  flex: 1;
  font-style: italic;
  color: #333;
}

.voice-line-context {
  font-size: 0.8em;
  color: #666;
}

.voice-line.ability {
  border-left: 3px solid #2e7d32;
  background: #e8f5e9;
}

.cookie-result {
  position: relative;
  overflow: hidden;
}

.cookie-result::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(198,40,40,0.08));
  pointer-events: none;
}

.flavor-text {
  text-align: center;
  color: #d81b60;
  font-weight: 600;
  margin-top: 8px;
  min-height: 24px;
}

.flavor-text.bounce { animation: subtle-bounce 500ms ease; }

@keyframes subtle-bounce {
  0% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
  60% { transform: translateY(0); }
  80% { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}

.like-button {
  background: #eee;
  color: #333;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  margin-top: 5px;
}
.like-button.liked { background: #ffebee; color: #d81b60; }

.collapsible h2 { display:flex; align-items:center; justify-content:flex-start; gap:8px; margin-bottom: 15px; }
.minimize-toggle { background:#ff80ab; color:#ffffff; padding:4px 10px; border-radius:6px; font-size:14px; }
.collapsible.collapsed > :not(h2) { display:none; }

/* Sub-collapsible sections (Battle Lab, Ship/Placeholder area) */
.collapsible-sub .sub-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:8px;
}
.collapsible-sub.collapsed > :not(.sub-header) {
  display:none;
}
.collapsible-sub .minimize-toggle {
  padding:2px 8px;
  font-size:12px;
  background:#ff80ab;
  color:#ffffff;
}

/* Dark / themed tweaks for sub-collapsibles */
body.dark .collapsible-sub .minimize-toggle {
  background:#80ffb3;
  color:#1b1b20;
}
body.chocolate .collapsible-sub .minimize-toggle {
  background:#ff80ab;
  color:#3e2723;
}
body.mint .collapsible-sub .minimize-toggle {
  background:#ff80ab;
  color:#104234;
}

.theme-toggle {
  background:#0b1c3a;
  color:#e0f7ff;
  padding:8px 12px;
  border-radius:6px;
  font-size:14px;
  border:1px solid #00e5ff;
  cursor:pointer;
  float:right;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

/* Switch (Ship Mode) */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { display:none; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  transition: background 0.2s;
}
.slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .slider { background: #d81b60; }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* Placeholder selection cards reuse saved-cookie-card */
.placeholder-card.selected {
  background: #fce4ec;
  border: 2px solid #d81b60;
  box-shadow: 0 4px 8px rgba(216,27,96,0.2);
}

/* Smaller disguise switch for Candy Apple / Apple Faerie toggle */
.disguise-switch {
  width: 36px;
  height: 20px;
  margin-top: 6px;
}
.disguise-switch .slider:before {
  width: 16px;
  height: 16px;
  top: 2px;
  left: 2px;
}
.disguise-switch input:checked + .slider:before {
  transform: translateX(16px);
}
/* Dark mode adjustments for switch/placeholder */
body.dark .slider { background:#333; }
body.dark .switch input:checked + .slider { background:#ff8fb0; }
body.dark .placeholder-card.selected { background:#1c2a1c; border-color:#81c784; }

/* Advanced promoting */
.advanced-toggle {
  background:#eee;
  color:#333;
  padding:8px 12px;
  border-radius:6px;
  border:none;
  cursor:pointer;
  font-size:14px;
  align-self:flex-start;
}
.advanced-toggle.active { background:#dcdcdc; }

.advanced-section {
  background:#f8f8f8;
  border-radius:8px;
  padding:15px;
  margin:10px 0 0 0;
}
.advanced-grid {
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
}
.skins-advanced {
  display:grid;
  grid-template-columns: 160px 1fr;
  gap:10px;
}
#advancedSkinsSpec { min-height: 80px; }
#advancedAppearance, #advancedPersonality, #advancedBackstory, #advancedAbility, #advancedVoice, #advancedExtra { min-height: 80px; }

/* Dark mode adjustments */
body.dark .advanced-section { background:#1b1b20; }
body.dark .advanced-toggle { background:#2a2a2f; color:#ddd; }
body.dark .advanced-toggle.active { background:#33333a; }

/* rest dark styles */
body.dark { background:#0f0f10; color:#eaeaea; }
body.dark, body.dark * {
  color: #ffffff !important;
}
body.dark .container { background:#141417; }
body.dark h1, body.dark h2, body.dark h3, body.dark h4 { color:#b3ffb3; }
body.dark #cookieInfo, body.dark .cookie-interaction-section, body.dark .chat-messages { background:#1b1b20; color:#eaeaea; }
body.dark #arenaBattleResult,
body.dark #interactionResult { background:#1b1b20; }
body.dark #generateArenaBattleBtn { background:#ba68c8; }
body.dark #generateArenaBattleBtn:hover { background:#9c27b0; }
body.dark .chat-message { background:#22222a; }
body.dark .chat-message.own-message { background:#2a1e24; }
body.dark input, body.dark textarea, body.dark select { background:#1a1a1f; color:#eaeaea; border-color:#333; }
body.dark .saved-cookie-card, body.dark .view-cookie-card { background:#1b1b20; color:#eaeaea; }
body.dark .reference-cookie-card { background:#000000; color:#eaeaea; }
body.dark .reference-cookie-card.selected, body.dark .saved-cookie-card.selected { background:#1c2a1c; border-color:#81c784; }
body.dark .share-button { background:#3b6fb3; }
body.dark .share-button:hover { background:#2e5c95; }
body.dark .minimize-toggle { background:#80ffb3; color:#1b1b20; }
body.dark .like-button { background:#2a2a2f; color:#ddd; }
body.dark .like-button.liked { background:#203f28; color:#8fffaf; }

/* Chocolate theme: rich cocoa / bakery vibe */
body.chocolate {
  background:
    radial-gradient(circle at top, #4e342e 0, #3e2723 35%, #2b1b16 70%, #1b100c 100%);
  color: #fbe9e7;
}
body.chocolate, body.chocolate * {
  color: #ffffff !important;
}
body.chocolate .container {
  background: rgba(38, 24, 20, 0.95);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border-radius: 18px;
}

/* Headings & text */
body.chocolate h1,
body.chocolate h2,
body.chocolate h3,
body.chocolate h4 {
  color: #ffe0b2;
}

/* Inputs */
body.chocolate input,
body.chocolate textarea,
body.chocolate select {
  background: #3b2721;
  border-color: #6d4c41;
  color: #ffe0b2;
}
body.chocolate input::placeholder,
body.chocolate textarea::placeholder {
  color: #a1887f;
}

/* Generic buttons */
body.chocolate button {
  background: #6d4c41;
  color: #fff3e0;
}
body.chocolate button:hover {
  background: #4e342e;
}

/* Special buttons */
body.chocolate #generateBtn {
  background: #8d4f3a;
}
body.chocolate #generateBtn:hover {
  background: #6d3324;
}
body.chocolate .share-button {
  background: #a1887f;
}
body.chocolate .share-button:hover {
  background: #7b5e57;
}
body.chocolate .save-button {
  background: #5d4037;
}
body.chocolate .save-button:hover {
  background: #3e2723;
}
body.chocolate .submit-event-button {
  background: #bf8040;
  color: #2b1809;
}
body.chocolate .submit-event-button:hover {
  background: #a66a2f;
}

/* Cards & panels */
body.chocolate .saved-cookie-card,
body.chocolate .view-cookie-card,
body.chocolate .reference-cookie-card,
body.chocolate .cookie-interaction-section,
body.chocolate .chat-messages,
body.chocolate #cookieInfo,
body.chocolate .world-maker-inner,
body.chocolate .community-cookies,
body.chocolate .cookie-interaction-area {
  background: #4e342e; /* richer chocolate brown */
  border-radius: 12px;
}
body.chocolate .saved-cookie-card.selected,
body.chocolate .reference-cookie-card.selected {
  background: #4e342e;
  border-color: #ffb74d;
  box-shadow: 0 0 0 2px rgba(255, 183, 77, 0.5);
}

/* Toggles / pills */
body.chocolate .minimize-toggle {
  background: #ff80ab;
  color: #3e2723;
}
body.chocolate .advanced-toggle {
  background: #4e342e;
  color: #ffe0b2;
}
body.chocolate .advanced-toggle.active {
  background: #5d4037;
}
body.chocolate .theme-toggle {
  background: #4e342e;
  color: #ffe0b2;
}

/* Likes */
body.chocolate .like-button {
  background: #3b2721;
  color: #ffcc80;
}
body.chocolate .like-button.liked {
  background: #5d4037;
  color: #ffe0b2;
}

/* Element tags & chips */
body.chocolate .cookie-element-tag {
  background: #4e342e;
  color: #ffecb3;
}

/* Magic-candy row */
body.chocolate .magic-candy-row {
  background: #3b2721;
  border-color: #a1887f;
}

/* World result / modals */
body.chocolate .world-result {
  background: #2b1b16;
}
body.chocolate .cutscene-modal-content {
  background: #2b1b16;
  color: #ffe0b2;
}
body.chocolate .cutscene-modal-header h3 {
  color: #ffcc80;
}

/* Update tabs */
body.chocolate .update-tab {
  background: #4e342e;
  color: #ffe0b2;
}
body.chocolate .update-tab.active {
  background: #ffb74d;
  color: #3e2723;
}

/* Mint theme: cool green/teal */
body.mint {
  background: radial-gradient(circle at top, #e0fff3 0, #c2fff0 35%, #a8f5dd 70%, #8ee4cf 100%);
  color: #104234;
}
body.mint .container {
  background: rgba(245, 255, 252, 0.95);
}
body.mint h1, body.mint h2, body.mint h3, body.mint h4 {
  color: #00796b;
}
body.mint input, body.mint textarea, body.mint select {
  background:#f0fffb;
  border-color:#80cbc4;
}
body.mint .saved-cookie-card,
body.mint .view-cookie-card,
body.mint .reference-cookie-card {
  background:#f0fffb;
}
body.mint .saved-cookie-card.selected,
body.mint .reference-cookie-card.selected {
  background:#e0f7fa;
  border-color:#26a69a;
}
body.mint .share-button {
  background:#26a69a;
}
body.mint .share-button:hover {
  background:#00897b;
}
body.mint .minimize-toggle {
  background:#ff80ab;
  color:#104234;
}
body.mint .like-button {
  background:#e0f2f1;
  color:#004d40;
}
body.mint .like-button.liked {
  background:#80cbc4;
  color:#00251a;
}

/* Vanilla (Light) theme: bright cookie pastel, using cookie background art */
body.vanilla {
  background-color: #ffeef5;
  background-image: url('/cookie_background.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  color: #4e342e;
}

body.vanilla .container {
  background: rgba(255, 253, 250, 0.96);
  color: #4e342e;
  box-shadow:
    0 0 18px rgba(255, 182, 193, 0.35),
    0 12px 24px rgba(0, 0, 0, 0.15);
}

body.vanilla h1,
body.vanilla h2,
body.vanilla h3,
body.vanilla h4 {
  color: #d81b60;
  text-shadow: 0 0 10px rgba(255, 182, 193, 0.6);
}

body.vanilla input,
body.vanilla textarea,
body.vanilla select {
  background: #fffdf9;
  border-color: #f8bbd0;
  color: #4e342e;
}

body.vanilla input::placeholder,
body.vanilla textarea::placeholder {
  color: #b3889b;
}

body.vanilla button {
  background: #ff80ab;
  color: #ffffff;
}

body.vanilla button:hover {
  background: #ff5c8d;
}

body.vanilla #generateBtn {
  background: #ffb300;
  color: #4e342e;
}

body.vanilla #generateBtn:hover {
  background: #ffa000;
}

body.vanilla .saved-cookie-card,
body.vanilla .view-cookie-card,
body.vanilla .reference-cookie-card,
body.vanilla .cookie-interaction-section,
body.vanilla .chat-messages,
body.vanilla #cookieInfo,
body.vanilla .world-maker-inner,
body.vanilla .community-cookies,
body.vanilla .cookie-interaction-area {
  background: #fffafc;
}

body.vanilla .saved-cookie-card.selected,
body.vanilla .reference-cookie-card.selected {
  background: #ffe4f0;
  border-color: #ff80ab;
  box-shadow: 0 0 0 2px rgba(255, 128, 171, 0.4);
}

body.vanilla .minimize-toggle {
  background: #ff80ab;
  color: #4e342e;
}

body.vanilla .like-button {
  background: #ffe4f0;
  color: #ad1457;
}

body.vanilla .like-button.liked {
  background: #ffb6e1;
  color: #880e4f;
}

body.vanilla .update-banner {
  background: linear-gradient(90deg, #ff80ab, #ffb74d);
  color: #4e342e;
}

body.vanilla .theme-toggle {
  background: #ffe4f0;
  color: #ad1457;
  border-color: #ff80ab;
}

body.vanilla .cookie-element-tag {
  background: #ffe4f0;
  color: #ad1457;
}

/* EVIL theme: Dark Enchantress–inspired reds, browns, and blacks */
body.evil {
  background:
    radial-gradient(circle at top, #3b0008 0, #240007 35%, #120005 70%, #050003 100%);
  color: #fbe9e7;
}
body.evil .container {
  background: rgba(20, 4, 6, 0.96);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  border-radius: 18px;
  border: 1px solid rgba(244, 67, 54, 0.4);
}

/* Headings & text */
body.evil h1,
body.evil h2,
body.evil h3,
body.evil h4 {
  color: #ff8a80;
}

/* Inputs */
body.evil input,
body.evil textarea,
body.evil select {
  background: #1b0507;
  border-color: #4e1516;
  color: #ffe0e0;
}
body.evil input::placeholder,
body.evil textarea::placeholder {
  color: #b26a6a;
}

/* Generic buttons */
body.evil button {
  background: #7f1b25;
  color: #ffebee;
}
body.evil button:hover {
  background: #5c111a;
}

/* Special buttons */
body.evil #generateBtn {
  background: #c62828;
}
body.evil #generateBtn:hover {
  background: #8e0000;
}
body.evil .share-button {
  background: #ad1457;
}
body.evil .share-button:hover {
  background: #880e4f;
}
body.evil .save-button {
  background: #6d1b1b;
}
body.evil .save-button:hover {
  background: #4e0f10;
}
body.evil .submit-event-button {
  background: #ff7043;
  color: #2b0500;
}
body.evil .submit-event-button:hover {
  background: #f4511e;
}

/* Cards & panels */
body.evil .saved-cookie-card,
body.evil .view-cookie-card,
body.evil .reference-cookie-card,
body.evil .cookie-interaction-section,
body.evil .chat-messages,
body.evil #cookieInfo,
body.evil .world-maker-inner,
body.evil .community-cookies,
body.evil .cookie-interaction-area {
  background: #1a0608;
  border-radius: 12px;
}
body.evil .saved-cookie-card.selected,
body.evil .reference-cookie-card.selected,
body.evil .placeholder-card.selected {
  background: #33060c;
  border-color: #ff5252;
  box-shadow: 0 0 0 2px rgba(239, 83, 80, 0.6);
}

/* Toggles / pills */
body.evil .minimize-toggle {
  background: #c62828;
  color: #ffe5e5;
}
body.evil .advanced-toggle {
  background: #2a080a;
  color: #ffebee;
}
body.evil .advanced-toggle.active {
  background: #3b0c10;
}
body.evil .theme-toggle {
  background: #2a080a;
  color: #ffebee;
}

/* Likes */
body.evil .like-button {
  background: #26080a;
  color: #ffab91;
}
body.evil .like-button.liked {
  background: #4e1516;
  color: #ffebee;
}

/* Magic-candy row */
body.evil .magic-candy-row {
  background: #25070a;
  border-color: #b71c1c;
}

/* World result / modals */
body.evil .world-result {
  background: #110305;
}
body.evil .cutscene-modal-content {
  background: #1b0507;
  color: #ffebee;
}
body.evil .cutscene-modal-header h3 {
  color: #ff8a80;
}

/* Update tabs */
body.evil .update-tab {
  background: #2a080a;
  color: #ffebee;
}
body.evil .update-tab.active {
  background: #e53935;
  color: #1b0505;
}

/* Element tags & chips */
body.evil .cookie-element-tag {
  background: #2c090c;
  color: #ffab91;
}

/* Banner */
body.evil .update-banner {
  background: linear-gradient(90deg, #b71c1c, #880e4f);
}

/* Chat bubbles */
body.evil .chat-message {
  background: #20060a;
}
body.evil .chat-message.own-message {
  background: #3b0c10;
}

.update-banner {
  background: linear-gradient(90deg, #0d47a1, #00bcd4);
  color: #e0f7ff;
  padding: 10px 16px;
  text-align: center;
  font-weight: 700;
  border-radius: 8px;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 0 16px rgba(0, 188, 212, 0.6);
}

/* Event modal */
.event-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.event-modal.hidden {
  display: none;
}
.event-modal-content {
  background: #fff;
  max-width: 420px;
  width: 90%;
  padding: 20px 22px;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  text-align: left;
  position: relative;
}
.event-modal-content h2 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #6d4c41;
}
.event-modal-content p {
  margin: 6px 0;
  font-size: 0.95rem;
}
.event-modal-close {
  margin-top: 14px;
  width: 100%;
  background: #d81b60;
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}
body.dark .event-modal-content {
  background: #141417;
  color: #eaeaea;
}
body.dark .event-modal-close {
  background: #ffb74d;
  color: #141417;
}

/* Flashing prize info highlight */
.prize-info {
  font-weight: 700;
  color: #ffffff;
  background: #ff69b4;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: center;
  animation: prize-flash 0.8s infinite alternate;
}

@keyframes prize-flash {
  0% {
    background: #ff69b4;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(255, 105, 180, 0.6);
    transform: scale(1);
  }
  100% {
    background: #ffb6e1;
    color: #ffffff;
    box-shadow: 0 0 14px rgba(255, 105, 180, 0.9);
    transform: scale(1.03);
  }
}

/* Submit to event button */
.submit-event-button {
  background: #ffb74d;
  color: #4e2a00;
}
.submit-event-button:hover {
  background: #ffa726;
}

body.dark .submit-event-button {
  background: #ffb74d;
  color: #3b1f00;
}
body.dark .submit-event-button:hover {
  background: #ffa726;
}

/* Optional: make element tags stand out slightly */
.cookie-element-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 10px;
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.75em;
  font-weight: 600;
}
body.dark .cookie-element-tag {
  background: #1c2a1c;
  color: #a5d6a7;
}

/* Dark-mode green variants for previously pink/purple accents */
body.dark #generateBtn {
  background: #66bb6a;
}
body.dark #generateBtn:hover {
  background: #43a047;
}

body.dark .update-banner {
  background: linear-gradient(90deg, #66bb6a, #43a047);
}

body.dark .skin-entry[data-rarity="Epic"] {
  border-left-color: #66bb6a;
}
body.dark .skin-entry[data-rarity="Epic"] .skin-rarity {
  background: #66bb6a;
}

body.dark .guest-dialogues .dialogue-block {
  border-left-color: #66bb6a;
}

body.dark .world-stage .stage-cutscene {
  color: #81c784;
}

.element-help {
  font-size: 0.8em;
  color: #666;
  margin-top: -6px;
  margin-bottom: 12px;
  line-height: 1.4;
}
body.dark .element-help {
  color: #aaa;
}

#cookieElementSecondary {
  border-width: 3px;
  border-color: #ff80ab;
  background: #fff3f8;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(255, 128, 171, 0.25);
  color: #4e342e;
}

#customElementName,
#customElementDescription {
  margin-top: 6px;
}

/* In chocolate mode, make the secondary element text black for better contrast */
body.chocolate #cookieElementSecondary {
  color: #000000;
}

#cookieElement {
  color: #4e342e;
}

/* Optional extra clarity: make Chaos tags stand out slightly with a darker accent */
.cookie-element-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 10px;
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.75em;
  font-weight: 600;
}
body.dark .cookie-element-tag {
  background: #1c2a1c;
  color: #a5d6a7;
}

body.dark #cookieElementSecondary {
  border-color: #81c784;
  background: #10231a;
  box-shadow: 0 0 0 2px rgba(129, 199, 132, 0.55);
}

/* Guest dialogue styling */
.guest-dialogues {
  margin-top: 20px;
  padding: 15px;
  background: #f8f8f8;
  border-radius: 8px;
}
.guest-dialogues .dialogue-block {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #ffffff;
  border-radius: 6px;
  border-left: 3px solid #6d4c41;
}
.guest-dialogues p {
  margin: 3px 0;
}
body.dark .guest-dialogues {
  background: #1b1b20;
}
body.dark .guest-dialogues .dialogue-block {
  background: #22222a;
  border-left-color: #ff8fb0;
}

/* Force white-style panels to go fully black in dark mode */
body.dark .world-stage,
body.dark .skin-entry,
body.dark .voice-lines-section,
body.dark .voice-line,
body.dark .guest-dialogues,
body.dark .guest-dialogues .dialogue-block {
  background: #000000;
}

/* Update Generator tabs */
.update-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 10px 0;
}

.update-tab {
  flex: 1;
  min-width: 90px;
  padding: 6px 8px;
  font-size: 12px;
  background: #eee;
  color: #333;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}

.update-tab.active {
  background: #6d4c41;
  color: #fff;
}

.update-tab-panels {
  margin-top: 4px;
}

.update-tab-panel {
  display: none;
}

.update-tab-panel.active {
  display: block;
}

.update-tab-panel textarea {
  width: 100%;
  min-height: 120px;
  margin-top: 4px;
}

/* Theatre tabs (under World Maker) */
.theatre-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 10px 0;
}

.theatre-tab {
  flex: 1;
  min-width: 90px;
  padding: 6px 8px;
  font-size: 12px;
  background: #eee;
  color: #333;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}

.theatre-tab.active {
  background: #6d4c41;
  color: #fff;
}

.theatre-panels {
  margin-top: 4px;
}

.theatre-panel {
  display: none;
}

.theatre-panel.active {
  display: block;
}

.theatre-controls textarea {
  width: 100%;
  min-height: 80px;
}

/* Dark mode for theatre tabs */
body.dark .theatre-tab {
  background: #2a2a2f;
  color: #ddd;
}

body.dark .theatre-tab.active {
  background: #8fffaf;
  color: #141417;
}

/* Chocolate & themed tweaks */
body.chocolate .theatre-tab {
  background: #4e342e;
  color: #ffe0b2;
}
body.chocolate .theatre-tab.active {
  background: #ffb74d;
  color: #3e2723;
}

body.mint .theatre-tab {
  background: #e0f7fa;
  color: #104234;
}
body.mint .theatre-tab.active {
  background: #26a69a;
  color: #ffffff;
}

body.evil .theatre-tab {
  background: #2a080a;
  color: #ffebee;
}
body.evil .theatre-tab.active {
  background: #e53935;
  color: #1b0505;
}

/* Dark mode for update tabs */
body.dark .update-tab {
  background: #2a2a2f;
  color: #ddd;
}

body.dark .update-tab.active {
  background: #8fffaf;
  color: #141417;
}

/* Chocolate mode chat text override: keep chat readable in dark cocoa UI */
body.chocolate .chat-messages,
body.chocolate .chat-messages * {
  color: #000000 !important;
}

/* Admin panel */
.admin-panel {
  margin-top: 24px;
  padding: 16px;
  border-radius: 10px;
  background: #fff8e1;
  border: 1px solid #ffe082;
}
.admin-panel h2 {
  margin-top: 0;
  color: #f57c00;
}
.admin-panel textarea {
  width: 100%;
  min-height: 70px;
  margin: 8px 0;
}
.admin-panel .admin-status {
  font-size: 0.85em;
  color: #666;
  margin-top: 6px;
}
body.dark .admin-panel {
  background: #1b1b20;
  border-color: #ffb74d;
}
body.chocolate .admin-panel {
  background: #3b2721;
  border-color: #ffb74d;
}

/* Announcement popup */
.announcement-popup {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  pointer-events: none;
}
.announcement-popup-inner {
  max-width: 520px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 248, 225, 0.97);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  border: 1px solid #ffb74d;
  font-size: 0.95rem;
  font-weight: 600;
  color: #5d4037;
}
.announcement-popup-inner p {
  margin: 0;
}
body.dark .announcement-popup-inner {
  background: rgba(20, 20, 23, 0.98);
  border-color: #66bb6a;
  color: #eaeaea;
}
body.chocolate .announcement-popup-inner {
  background: rgba(38, 24, 20, 0.98);
  border-color: #ffb74d;
  color: #fff3e0;
}

/* Talk-to-cookie popup */
.talk-popup {
  position: fixed;
  top: 80px;
  left: 50px;
  width: 280px;
  min-width: 220px;
  max-width: 420px;
  height: 380px;
  min-height: 220px;
  z-index: 4000;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  overflow: auto; /* outer popup now scrolls too, giving a second scrollbar */
  resize: both; /* allow manual scaling with mouse, then scroll inside */
}

body.dark .talk-popup {
  background: #141417;
}

body.chocolate .talk-popup {
  background: #2b1b16;
}

.talk-popup.small {
  width: 220px;
  height: 240px;
}

.talk-popup.large {
  width: 420px;
  height: 520px;
}

.talk-popup-header {
  cursor: move;
  user-select: none;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: linear-gradient(90deg, #ff80ab, #f06292);
  color: #fff;
  font-size: 0.85rem;
}

body.dark .talk-popup-header {
  background: linear-gradient(90deg, #66bb6a, #43a047);
}

body.evil .talk-popup-header {
  background: linear-gradient(90deg, #b71c1c, #880e4f);
}

.talk-popup-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.talk-popup-title span {
  display: block;
  line-height: 1.2;
}

.talk-popup-title .cookie-name {
  font-weight: 700;
}

.talk-popup-title .cookie-role {
  font-size: 0.75em;
  opacity: 0.9;
}

.talk-popup-header-buttons {
  display: flex;
  gap: 4px;
}

.talk-popup-header-buttons button {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 6px;
  background: rgba(0,0,0,0.15);
  color: #fff;
  box-shadow: none;
}

.talk-popup-header-buttons button:hover {
  background: rgba(0,0,0,0.3);
  transform: none;
}

.talk-popup-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 4px;
}

.talk-popup-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  border-radius: 6px;
  background: #f8f8f8;
  font-size: 0.8rem;

  /* enable touch scrolling & show mini-scrollbar similar to main chat */
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;

  /* mini-scrollbar like main chat */
  scrollbar-width: thin;           /* Firefox */
  scrollbar-color: #ff80ab #f8f8f8;
}

/* WebKit browsers */
.talk-popup-messages::-webkit-scrollbar {
  width: 6px;
}

.talk-popup-messages::-webkit-scrollbar-track {
  background: #f8f8f8;
  border-radius: 8px;
}

.talk-popup-messages::-webkit-scrollbar-thumb {
  background: #ff80ab;
  border-radius: 8px;
}

.talk-popup-messages::-webkit-scrollbar-thumb:hover {
  background: #f06292;
}

body.dark .talk-popup-messages {
  background: #1b1b20;
}

body.chocolate .talk-popup-messages {
  background: #3b2721;
}

.talk-line {
  margin-bottom: 4px;
}

.talk-line span.role {
  font-weight: 700;
  margin-right: 4px;
}

.talk-line.user span.role {
  color: #1976d2;
}

.talk-line.cookie span.role {
  color: #d81b60;
}

body.dark .talk-line.user span.role {
  color: #8fffaf;
}

body.dark .talk-line.cookie span.role {
  color: #ff8fb0;
}

.talk-popup-input-row {
  display: flex;
  margin-top: 4px;
  gap: 4px;
}

.talk-popup-input-row input {
  flex: 1;
  padding: 6px 8px;
  font-size: 0.8rem;
}

.talk-popup-input-row button {
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  background: #ff80ab;
}

.talk-popup-input-row button:hover {
  background: #ff4081;
}

/* Ensure talk popup floats above announcement & cutscene modals */
.talk-popup {
  z-index: 4000;
}
