/* Base styles */
body { 
  margin: 0; 
  overflow: hidden; 
}

html {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

canvas { 
  display: block; 
}

/* Debug Panel */
#controls {
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 10px;
  border-radius: 0 0 5px 0;
  z-index: 1999;
  max-width: 90%;
  transition: all 0.3s ease;
  max-height: 80vh;
  overflow-y: auto;
  font-family: monospace;
  font-size: 12px;
}

#controls.collapsed { 
  max-height: 45px; 
  overflow: hidden; 
}

#controls.hidden {
  display: none !important;
}

#toggle-controls { 
  cursor: pointer; 
  user-select: none; 
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 10px;
}

#toggle-icon { 
  margin-left: 8px; 
  transition: transform 0.3s ease; 
}

.collapsed #toggle-icon { 
  transform: rotate(-90deg); 
}

.control-content {
  display: block;
  transition: all 0.3s ease;
}

.collapsed .control-content {
  display: none;
}

.control-group { 
  margin-bottom: 10px; 
  display: flex; 
  align-items: center; 
  flex-wrap: wrap; 
}

label { 
  width: 120px; 
  display: inline-block;
  color: #ccc; 
}

.value-display { 
  font-family: monospace; 
  margin-left: 5px; 
  min-width: 50px; 
}

button {
  padding: 5px 10px; 
  background: rgba(60,60,60,0.5); 
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3); 
  border-radius: 3px; 
  cursor: pointer;
  font-family: monospace; 
  font-size: 12px;
  margin-right: 5px;
}

button:hover { 
  background: rgba(80,80,80,0.7); 
}

button.active { 
  background: rgba(0,120,200,0.7); 
}

/* Debug information styles */
.debug-section {
  margin-bottom: 10px;
  padding: 5px 0;
  border-top: 1px solid rgba(255,255,255,0.3);
}

.debug-header {
  color: #8af;
  margin-top: 5px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: bold;
}

.debug-group {
  margin-bottom: 3px;
  display: flex;
  flex-wrap: wrap;
}

.debug-label {
  width: 140px;
  color: #ccc;
}

.debug-value {
  font-family: monospace;
  word-wrap: break-word;
}

/* Terminal Help Command Styles */
.help-header {
  font-weight: bold;
  color: #5affff;
  margin-bottom: 5px;
  padding-bottom: 3px;
  border-bottom: 1px solid #4a7a7a;
}

.command-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 5px;
}

.command-item {
  display: flex;
  gap: 10px;
  padding-left: 10px;
}

.command-name {
  font-weight: bold;
  color: #ffff80;
  min-width: 80px;
}

.command-desc {
  color: #aaddff;
}

/* Terminal overlay */
#terminal-overlay {
  display: none;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 600px;
  background: rgba(0,0,0,0.8);
  border-radius: 5px 5px 0 0;
  border: 1px solid rgba(0,255,255,0.5);
  border-bottom: none;
  padding: 10px;
  font-family: monospace;
  color: white;
  z-index: 2001;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

#terminal-input {
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-family: monospace;
  width: calc(100% - 20px);
  caret-color: #00ff00;
  font-size: 14px;
}

#terminal-prompt {
  color: #00ff00;
  margin-right: 5px;
}

#command-response {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
  color: #aaddff;
  font-size: 13px;
  padding-top: 5px;
  display: none;
}

.command-success {
  color: #66ff66;
}

.command-error {
  color: #ff6666;
}

/* Console indicator */
#console-indicator {
  position: fixed;
  bottom: 0;
  right: 0;
  font-family: monospace;
  font-size: 12px;
  color: rgba(200,200,200,0.7);
  background: rgba(0,0,0,0.5);
  padding: 5px 8px;
  border-radius: 5px 0 0 0;
  pointer-events: auto;
  z-index: 2000;
  border: 1px solid rgba(100,100,100,0.3);
  border-bottom: none;
  border-right: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#console-indicator:hover {
  background: rgba(0,0,0,0.7);
  color: rgba(255,255,255,0.9);
}

/* Animations */
@keyframes highlight {
  0% { background: rgba(0,255,255,0.2); }
  100% { background: rgba(0,0,0,0.7); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.terminal-blink {
  animation: blink 1s infinite;
}

/* Terminal input container */
.terminal-input-container {
  display: flex;
  align-items: center;
}

#terminal-prompt {
  color: #00ff00;
  margin-right: 5px;
  display: inline-block;
}

#terminal-input {
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-family: monospace;
  width: 100%;
  caret-color: #00ff00;
  font-size: 14px;
  padding: 0;
  margin: 0;
  flex: 1;
}

/* RGB color sliders */
.rgb-sliders {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.rgb-slider {
  display: flex;
  align-items: center;
}

.rgb-slider label {
  width: 60px;
  font-weight: bold;
}

.rgb-slider input[type="range"] {
  flex-grow: 1;
}

.rgb-red label {
  color: #ff6666;
}

.rgb-green label {
  color: #66ff66;
}

.rgb-blue label {
  color: #6666ff;
}

.color-preview {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid #fff;
  margin-left: 10px;
}

input[type="checkbox"] {
  margin-right: 5px;
}

/* Mobile styles */
@media screen and (max-width: 768px) {
  #console-indicator {
    padding: 10px 15px;
    font-size: 14px;
    background: rgba(0,0,0,0.7);
  }
  
  label { width: 100px; }
  .debug-label { width: 120px; }
  
  #controls {
    max-width: 85%;
    max-height: 70vh;
    -webkit-overflow-scrolling: touch;
  }
  
  #terminal-overlay {
    width: 90%;
    max-width: none;
    padding: 8px;
    bottom: 40px;
  }
  
  #terminal-input {
    width: calc(100% - 15px);
    font-size: 16px;
  }
  
  /* Make interactive elements more touch-friendly */
  input[type="range"] {
    height: 24px;
  }
  
  button {
    padding: 8px 12px;
    margin-bottom: 5px;
    min-width: 80px;
  }
}

/* Small mobile devices */
@media screen and (max-width: 375px) {
  #controls {
    max-width: 95vw;
    font-size: 11px;
  }
  
  #terminal-overlay {
    width: 95%;
    bottom: 35px;
  }
  
  .debug-label {
    width: 100px;
  }
}

#menu-trigger-container {
  position: fixed;
  top: 35%;  /* Position wherever you want */
  right: 15%;
  transform: translateY(-50%);
  z-index: 1501; /* Make sure it's above the menu */
  font-family: 'Arial', sans-serif;
  user-select: none;
}

/* Floating Menu Styles */
#floating-menu-container {
  position: fixed;
  top: 50%;
  right: 10%;
  transform: translateY(-50%);
  z-index: 1500;
  font-family: 'Arial', sans-serif;
  user-select: none;
  /* Add a fixed width to contain both menu trigger and categories */
  width: auto;
  /* Ensure text alignment is consistent */
  text-align: left;
}


#menu-trigger {
  font-size: 36px;
  font-weight: 700;
  color: rgba(220, 220, 220, 0.9);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all 0.5s ease;
  text-align: left;
  /* Make position absolute to the container */
  position: relative;
  /* Set left margin to 0 to ensure alignment with categories */
  margin-left: 0;
  display: block;
}

#menu-trigger:hover {
  color: rgba(240, 240, 240, 1);
  text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.6);
  transform: scale(1.05);
}

/* Main menu styling to ensure alignment with trigger */
#main-menu {
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  text-align: left;
  /* Position relative to container */
  position: relative;
  /* Ensure left alignment matches the trigger */
  left: 0;
}

#main-menu.visible {
  opacity: 1;
  pointer-events: all;
}

.menu-categories {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-category {
  margin: 15px 0;
  position: relative;
}

/* Ensure category titles align with the menu trigger */
.category-title {
  font-size: 28px;
  font-weight: 700;
  color: rgba(220, 220, 220, 0.9);
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 1px;
  display: block;
  /* Ensure text starts at the same position as the trigger */
  margin-left: 0;
  position: relative;
}

/* Ensure hover effect doesn't break alignment */
.category-title:hover {
  color: rgba(240, 240, 240, 1);
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
  /* Use padding instead of transform for hover effect to maintain alignment */
  padding-left: 5px;
  /* Remove transform that would shift alignment */
  transform: none;
}

/* Responsive adjustments for different screen sizes */
@media screen and (max-width: 768px) {
  #floating-menu-container {
    right: 5%;
  }
  
  #menu-trigger {
    font-size: 30px;
  }
  
  .category-title {
    font-size: 24px;
  }
}

@media screen and (max-width: 480px) {
  #floating-menu-container {
    right: 5%;
    width: auto;
  }
  
  #menu-trigger {
    font-size: 24px;
  }
  
  .category-title {
    font-size: 20px;
  }
}

.submenu {
  list-style: none;
  padding: 0;
  margin: 5px 0 5px 20px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease;
  opacity: 0;
}

.menu-category:hover .submenu {
  max-height: 300px;
  opacity: 1;
}

.submenu-item {
  font-size: 18px;
  color: rgba(180, 180, 180, 0.8);
  margin: 8px 0;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: capitalize;
}

.submenu-item:hover {
  color: rgba(150, 255, 150, 1);
  transform: scale(1.1) translateX(10px);
}

.menu-divider {
  height: 1px;
  background: linear-gradient(to right, rgba(150, 150, 150, 0), rgba(150, 150, 150, 0.5), rgba(150, 150, 150, 0));
  margin: 5px 0;
  width: 100%;
}

/* Content Containers */
.content-section {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  max-width: 800px;
  height: 80%;
  max-height: 600px;
  background-color: rgba(30, 30, 30, 0.8);
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  z-index: 1400;
  display: none;
  padding: 20px;
  color: #e0e0e0;
  overflow-y: auto;
}

#content-containers.visible .content-section.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Content Close Button */
.content-close {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 24px;
  color: rgba(200, 200, 200, 0.8);
  cursor: pointer;
  transition: color 0.3s ease;
}

.content-close:hover {
  color: rgba(255, 100, 100, 1);
}