@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap');

body {
  font-family: 'Fredoka One', cursive, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: linear-gradient(to bottom right, #ffccdd, #cceeff);
  color: #333;
  min-height: 10vh; 
  margin: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark Mode Styles */
body.dark-mode {
    background: #1a1a2e; 
    color: #e0e0e0; 
}

body.dark-mode textarea {
    background-color: #2e2a42;
    border-color: #a780e0; 
    color: #e0e0e0; 
}

body.dark-mode button {
    background-color: #a780e0; 
    color: #1a1a2e; 
}

body.dark-mode button:hover {
    background-color: #c7a0ff; 
}

body.dark-mode #options,
body.dark-mode #add-oc,
body.dark-mode #characters,
body.dark-mode #music-selector {
    background-color: #2e2a42; 
    border-color: #5a4a6e; 
}

body.dark-mode #options label {
    color: #c7a0ff; 
}

body.dark-mode .gore-label {
    color: #ff6b6b; 
}

body.dark-mode #add-oc h2,
body.dark-mode #characters h2,
body.dark-mode #music-selector h2 {
    color: #c7a0ff; 
    border-bottom-color: #5a4a6e; 
}

body.dark-mode #add-oc input[type="text"],
body.dark-mode #add-oc textarea,
body.dark-mode #oc-search,
body.dark-mode #music-track-select {
    background-color: #3a3652; 
    border-color: #5a4a6e; 
    color: #e0e0e0; 
}

body.dark-mode .character-section-header {
    color: #a780e0; 
    border-bottom-color: #5a4a6e; 
}

body.dark-mode .character-row input[type="checkbox"] {
    border-color: #a780e0; 
    background-color: #3a3652; 
}

body.dark-mode .character-row input[type="checkbox"]:checked {
    background-color: #a780e0; 
}

body.dark-mode .character-row label {
    color: #c7a0ff; 
}

body.dark-mode .character-description {
    color: #a780e0; 
    opacity: 0.9;
}

body.dark-mode #placeholder {
    color: #8a71a3; 
}

body.dark-mode #output {
    background-color: #3a3652; 
    color: #e0e0e0; 
    border-color: #5a4a6e; 
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .switch input:checked+.slider {
    background-color: #ffabab; 
}

.nsfw-label {
    color: #e91e63 !important; 
    font-weight: bold;
}

body.dark-mode .nsfw-label {
    color: #ff80ab !important;
}

#nsfw-mode-warning {
    font-size: 0.9em;
    margin-top: 5px;
    padding: 10px;
    border: 1px solid #f48fb1;
    border-radius: 8px;
    color: #c2185b;
    background-color: #fce4ec;
    font-weight: bold;
}

body.dark-mode #nsfw-mode-warning {
    background-color: #4a1f2e;
    color: #ff80ab;
    border-color: #880e4f;
}

.ausuwtarat-label {
    color: #9c27b0 !important; 
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

body.dark-mode .ausuwtarat-label {
    color: #ce93d8 !important;
}

#ausuwtarat-mode-warning {
    font-size: 0.9em;
    margin-top: 5px;
    padding: 10px;
    border: 1px solid #ce93d8;
    border-radius: 8px;
    color: #6a1b9a;
    background-color: #f3e5f5;
    font-weight: bold;
}

body.dark-mode #ausuwtarat-mode-warning {
    background-color: #4a1942;
    color: #ce93d8;
    border-color: #6a1b9a;
}

.chaotic-label {
    color: #ff9100 !important; 
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: rainbow 3s linear infinite;
}

@keyframes rainbow {
    0% { color: #ff0000; }
    17% { color: #ff9100; }
    33% { color: #fff200; }
    50% { color: #00ff00; }
    67% { color: #0000ff; }
    83% { color: #9500ff; }
    100% { color: #ff0000; }
}

body.dark-mode .chaotic-label {
    animation: darkRainbow 3s linear infinite;
}

@keyframes darkRainbow {
    0% { color: #ff6666; }
    17% { color: #ffb366; }
    33% { color: #fff666; }
    50% { color: #66ff66; }
    67% { color: #6666ff; }
    83% { color: #b366ff; }
    100% { color: #ff6666; }
}

#chaotic-mode-warning {
    font-size: 0.9em;
    margin-top: 5px;
    padding: 10px;
    border: 2px solid #ff9100;
    border-radius: 8px;
    color: #ff6d00;
    background-color: #fff3e0;
    font-weight: bold;
    animation: warningPulse 2s ease-in-out infinite;
}

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

body.dark-mode #chaotic-mode-warning {
    background-color: #4a2700;
    color: #ffab40;
    border-color: #ff9100;
}

.way-too-much-label {
    color: #ff0000 !important; 
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: rainbow 3s linear infinite;
}

body.dark-mode .way-too-much-label {
    animation: darkRainbow 3s linear infinite;
}

#way-too-much-mode-warning {
    font-size: 0.9em;
    margin-top: 5px;
    padding: 15px;
    border: 3px solid #ff0000;
    border-radius: 12px;
    color: #d32f2f;
    background-color: #fff3e0;
    font-weight: bold;
    font-size: 1.1em;
    animation: warningPulse 1s ease-in-out infinite;
    text-align: center;
    line-height: 1.4;
}

body.dark-mode #way-too-much-mode-warning {
    background-color: #2a0000;
    color: #ff6b6b;
    border-color: #ff0000;
}

#way-too-much-mode-warning {
    font-size: 0.9em;
    margin-top: 5px;
    padding: 15px;
    border: 3px solid #ff0000;
    border-radius: 12px;
    color: #d32f2f;
    background-color: #fff3e0;
    font-weight: bold;
    font-size: 1.1em;
    animation: warningPulse 1s ease-in-out infinite;
    text-align: center;
    line-height: 1.4;
}

@keyframes wayTooMuchPulse {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.05) rotate(2deg); }
    50% { transform: scale(1.1) rotate(-2deg); }
    75% { transform: scale(1.05) rotate(1deg); }
    100% { transform: scale(1) rotate(0deg); }
}

#way-too-much-mode-warning {
    animation: wayTooMuchPulse 2s ease-in-out infinite;
}

body.dark-mode #way-too-much-mode-warning {
    background-color: #2a0000;
    color: #ff6b6b;
    border-color: #ff0000;
}

#fullLengthToggle:disabled + .slider {
    background-color: #9e9e9e;
    cursor: not-allowed;
}

body.dark-mode #fullLengthToggle:disabled + .slider {
    background-color: #424242;
}

#logo {
  width: 200px;
  margin-bottom: 20px;
}

h1 {
  color: #ff69b4;
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

textarea {
  width: 90%;
  max-width: 600px;
  height: 150px;
  margin-bottom: 15px;
  padding: 15px;
  border: 2px solid #ffb347;
  border-radius: 15px;
  font-size: 16px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  resize: vertical;
  background-color: #fff9c4;
  font-family: 'Fredoka One', cursive, sans-serif;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

textarea:hover {
  border-color: #ffa726;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

textarea:focus {
  outline: none;
  border-color: #ff9100;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

button {
  padding: 12px 24px;
  font-size: 18px;
  background-color: #8a2be2;
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.1s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  margin-top: 15px;
  font-weight: bold;
  font-family: 'Fredoka One', cursive, sans-serif;
}

button:hover {
  background-color: #6a1b9a;
}

button:active {
  transform: scale(0.98);
}

#options {
  width: 90%;
  max-width: 600px;
  margin-top: 15px;
  padding: 15px 20px;
  border: 1px solid #a5d6a7;
  border-radius: 15px;
  background-color: #e8f5e9;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

#options label {
  font-weight: bold;
  color: #2e7d32; 
  margin-right: 10px;
}

.gore-label {
    color: #d32f2f; 
    font-weight: bold;
}

#violent-mode-warning,
#gore-mode-warning { 
  font-size: 0.9em;
  margin-top: 5px;
  padding: 10px;
  border: 1px solid #ef9a9a;
  border-radius: 8px;
}

#violent-mode-warning {
  color: #c62828; 
  background-color: #ffcdd2;
}

#gore-mode-warning {
  color: #b71c1c; 
  background-color: #ffcdd2; 
  font-weight: bold; 
}

#add-oc,
#characters,
#output,
#music-selector {
  width: 90%;
  max-width: 600px;
  margin-top: 25px;
  padding: 20px;
  border: 1px solid #b39ddb;
  border-radius: 15px;
  background-color: #ede7f6;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#add-oc h2,
#characters h2,
#music-selector h2 {
  color: #5e35b1;
  margin-top: 0;
  margin-bottom: 15px;
  border-bottom: 1px solid #d1c4e9;
  padding-bottom: 10px;
  cursor: pointer; 
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#add-oc h2 span,
#characters h2 span {
  font-size: 1.2em;
  margin-left: 10px;
}

#oc-input-content {
  
}

#add-oc input[type="text"],
#add-oc textarea {
  width: calc(100% - 30px);
  margin-bottom: 10px;
  padding: 10px 15px;
  border: 1px solid #b39ddb;
  border-radius: 8px;
  font-size: 1em;
  font-family: 'Fredoka One', cursive, sans-serif;
  background-color: #f3e5f5;
}

#add-oc textarea {
  height: 80px;
  resize: vertical;
}

#add-oc button {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px;
  font-size: 1em;
}

#oc-search {
  width: calc(100% - 30px);
  margin-bottom: 15px;
  padding: 10px 15px;
  border: 1px solid #b39ddb;
  border-radius: 8px;
  font-size: 1em;
  font-family: 'Fredoka One', cursive, sans-serif;
  background-color: #f3e5f5;
}

.character-section-header {
  color: #7b1fa2;
  margin-top: 15px;
  margin-bottom: 8px;
  border-bottom: 1px dashed #e1bee7;
  padding-bottom: 3px;
  font-size: 1.1em;
}

.character-row {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
  flex-wrap: wrap;
  padding-right: 10px;
  justify-content: space-between;
  padding: 5px 10px;
  border-radius: 4px;
  margin-bottom: 5px;
}

.character-row input[type="checkbox"] {
  margin-right: 8px;
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #7b1fa2;
  border-radius: 4px;
  background-color: #f3e5f5;
  cursor: pointer;
  position: relative;
  top: 2px;
}

.character-row input[type="checkbox"]:checked {
  background-color: #7b1fa2;
}

.character-row input[type="checkbox"]:checked::after {
  content: '\2713';
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
}

.character-row label {
  margin-left: 0;
  flex-grow: 1;
  cursor: pointer;
  font-weight: bold;
  color: #4527a0;
}

.character-description {
  font-style: italic;
  color: #673ab7;
  margin-left: 30px;
  margin-top: 2px;
  margin-bottom: 8px;
  font-size: 0.85em;
  width: 100%;
  line-height: 1.3;
  padding-right: 15px;
  max-width: calc(100% - 45px);
}

#placeholder {
  text-align: center;
  font-style: italic;
  color: #9575cd;
  margin-top: 15px;
}

#output {
  white-space: pre-wrap;
  overflow-x: auto;
  font-family: 'Fredoka One', cursive, sans-serif;
  background-color: #fffde7;
  color: #3e2723;
  border: 1px solid #fff59d;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: #ff80ab;
}

input:focus+.slider {
  box-shadow: 0 0 1px #ff80ab;
}

input:checked+.slider:before {
  -webkit-transform: translateX(20px);
  -ms-transform: translateX(20px);
  transform: translateX(20px);
}

#character-list-content button {
  margin-top: 15px;
  margin-bottom: 5px;
  width: 100%;
  max-width: none; 
}

#select-all-characters {
  background-color: #4CAF50;
}

#select-all-characters:hover {
  background-color: #388E3C;
}

#deselect-all-characters {
  background-color: #f44336;
  margin-bottom: 20px;
}

#deselect-all-characters:hover {
  background-color: #d32f2f;
}

#select-all-main-chars {
  background-color: #2196F3;
}

#select-all-main-chars:hover {
  background-color: #1976D2;
}

#select-all-ocs {
  background-color: #FF9800;
}

#select-all-ocs:hover {
  background-color: #F57C00;
}

.hidden {
  display: none;
}

#music-selector select {
    width: calc(100% - 80px); 
    padding: 10px;
    border: 1px solid #b39ddb;
    border-radius: 8px;
    font-size: 1em;
    font-family: 'Fredoka One', cursive, sans-serif;
    background-color: #f3e5f5;
    margin-right: 10px; 
}

#music-selector button {
    padding: 10px 15px;
    font-size: 1em;
    margin-top: 0; 
    width: 70px; 
}

.music-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap; 
}

.type-selection {
  margin-bottom: 15px;
  display: flex;
  gap: 20px;
}

.type-selection label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #4527a0;
}

.type-selection input[type="radio"] {
  margin: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

body.dark-mode .type-selection label {
  color: #c7a0ff;
}

.edit-button,
.delete-button {
  padding: 2px 8px;
  margin: 0 2px;
  font-size: 16px;
  background: none;
  border: 1px solid #b39ddb;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: none;
  color: #7b1fa2;
}

.edit-button:hover,
.delete-button:hover {
  background-color: #ede7f6;
}

body.dark-mode .edit-button,
body.dark-mode .delete-button {
  color: #c7a0ff;
  border-color: #5a4a6e;
}

body.dark-mode .edit-button:hover,
body.dark-mode .delete-button:hover {
  background-color: #3a3652;
}

.emoji-input-container {
  position: relative;
  width: 100%;
  margin-bottom: 10px;
}

#add-emoji-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 10px;
  font-size: 16px;
  background: none;
  border: 1px solid #b39ddb;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: none;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#add-emoji-button:hover {
  opacity: 1;
}

.custom-emoji {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  display: inline-block;
  object-fit: contain;
}

body.dark-mode #add-emoji-button {
  border-color: #5a4a6e;
  color: #c7a0ff;
}

body.dark-mode #add-emoji-button:hover {
  background-color: #3a3652;
}

/* Mobile-friendly styles */
@media screen and (max-width: 768px) {
  body {
    padding: 10px;
  }

  #logo {
    width: 150px; /* Smaller logo on mobile */
  }

  textarea {
    width: 95%;
    padding: 10px;
    font-size: 14px;
  }

  button {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    font-size: 16px;
  }

  #options, #add-oc, #characters, #output, #music-selector, #script-history {
    width: 95%;
    padding: 15px;
    margin-top: 15px;
  }

  .option-row {
    padding: 8px 0;
  }

  .character-row {
    padding: 8px 5px;
  }

  .character-description {
    margin-left: 15px;
    font-size: 0.8em;
  }

  #character-list-content button {
    margin-top: 10px;
    margin-bottom: 5px;
  }

  .music-controls {
    flex-direction: column;
    gap: 10px;
  }

  #music-selector select {
    width: 100%;
    margin-right: 0;
    margin-bottom: 10px;
  }

  #music-selector button {
    width: 100%;
  }

  .script-entry {
    padding: 10px;
  }

  .script-entry .script-header {
    flex-direction: column;
    gap: 5px;
  }

  .script-entry .script-content {
    font-size: 0.85em;
    padding: 8px;
  }

  .type-selection {
    flex-direction: column;
    gap: 10px;
  }

  #oc-search {
    width: 95%;
  }
}

/* Touch-friendly improvements */
@media (hover: none) {
  button:hover {
    background-color: initial; /* Remove hover states on touch devices */
  }

  .character-row {
    min-height: 44px; /* Minimum touch target size */
  }

  .character-row input[type="checkbox"] {
    width: 24px;
    height: 24px;
  }

  .switch {
    width: 50px;
    height: 26px;
  }

  .slider:before {
    height: 22px;
    width: 22px;
  }

  input:checked + .slider:before {
    transform: translateX(24px);
  }
}

/* iPad/tablet specific adjustments */
@media screen and (min-width: 768px) and (max-width: 1024px) {
  body {
    padding: 15px;
  }

  #logo {
    width: 175px;
  }

  textarea, #options, #add-oc, #characters, #output, #music-selector, #script-history {
    width: 90%;
  }

  button {
    font-size: 17px;
    padding: 14px 28px;
  }
}

/* Dark mode adjustments for mobile */
@media screen and (max-width: 768px) {
  body.dark-mode #options,
  body.dark-mode #add-oc,
  body.dark-mode #characters,
  body.dark-mode #music-selector,
  body.dark-mode #script-history {
    background-color: #2a2a3a;
  }

  body.dark-mode .script-entry {
    background-color: #323242;
  }
}

/* Add new styles for script history section */
#script-history {
  width: 90%;
  max-width: 600px;
  margin-top: 25px;
  margin-bottom: 25px;
  padding: 20px;
  border: 1px solid #b39ddb;
  border-radius: 15px;
  background-color: #ede7f6;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#script-history h2 {
  color: #5e35b1;
  margin-top: 0;
  margin-bottom: 15px;
  border-bottom: 1px solid #d1c4e9;
  padding-bottom: 10px;
}

#my-scripts-section,
#other-scripts-section {
  margin-top: 15px;
}

#my-scripts-section h3,
#other-scripts-section h3 {
  color: #7b1fa2;
  margin-bottom: 10px;
  font-size: 1.1em;
}

.script-entry {
  background-color: #f3e5f5;
  border: 1px solid #d1c4e9;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.script-entry .script-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.9em;
  color: #673ab7;
}

.script-entry .script-content {
  white-space: pre-wrap;
  font-size: 0.9em;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  background-color: #fff;
  border-radius: 4px;
}

.script-entry .delete-script {
  padding: 2px 8px;
  font-size: 14px;
  background: none;
  border: 1px solid #b39ddb;
  border-radius: 4px;
  cursor: pointer;
  color: #d32f2f;
  margin-left: 10px;
}

.script-entry .delete-script:hover {
  background-color: #ffebee;
}

/* Dark mode styles for script history */
body.dark-mode #script-history {
  background-color: #2e2a42;
  border-color: #5a4a6e;
}

body.dark-mode #script-history h2,
body.dark-mode #script-history h3 {
  color: #c7a0ff;
  border-bottom-color: #5a4a6e;
}

body.dark-mode .script-entry {
  background-color: #3a3652;
  border-color: #5a4a6e;
}

body.dark-mode .script-entry .script-header {
  color: #a780e0;
}

body.dark-mode .script-entry .script-content {
  background-color: #2e2a42;
  color: #e0e0e0;
}

body.dark-mode .script-entry .delete-script {
  color: #ff6b6b;
  border-color: #5a4a6e;
}

body.dark-mode .script-entry .delete-script:hover {
  background-color: #4a2a2a;
}