/* Modern Linkage Designer CSS - Cleaned and Reorganized */

/* ================ VARIABLES ================ */
:root {
  /* Color Palette */
  --bg-primary: #ffffff;
  --bg-secondary: #ebebec;
  --bg-tertiary: #bbc0c6;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --accent-primary: #0d6efd;
  --accent-secondary: #6610f2;
  --accent-tertiary: #0dcaf0;
  --success: #198754;
  --warning: #ffc107;
  --danger: #dc3545;
  
  /* RGB variants for transparency */
  --bg-secondary-rgb: 248, 249, 250;
  --bg-tertiary-rgb: 233, 236, 239;
  --accent-tertiary-rgb: 13, 202, 240;
  
  /* Path Colors - Consistent across all modes */
  --path-color: #006ed5;          /* Default path color for all nodes */
  --motor-path-color: #ffc107;    /* Motor node path color */
  --target-path-color: #ff9900;   /* Target node path color */
  
  /* Layout */
  --sidebar-width: 250px;
  --border-radius: 8px;
  --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
  --real-vh: 100vh;
}

/* Dark Mode Variables */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #212529;
    --bg-secondary: #343a40;
    --bg-tertiary: #495057;
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --accent-primary: #3d8bfd;
    --accent-secondary: #8540f5;
    --accent-tertiary: #3dd5f3;
    --bg-secondary-rgb: 52, 58, 64;
    --bg-tertiary-rgb: 73, 80, 87;
  }
}

/* ================ RESET & GLOBAL STYLES ================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  height: 100%;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: var(--real-vh);
  width: 100vw;
}

/* ================ SIDEBAR STYLES ================ */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-header {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--bg-tertiary);
}

.sidebar-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.tools {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
}

.tool-section {
  margin-bottom: 20px;
}

.tool-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--bg-tertiary);
}

.tool-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px;
  margin-bottom: 5px;
  border: none;
  background-color: transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  color: var(--text-primary);
  font-family: inherit;
  transition: var(--transition);
}

.tool-btn i {
  margin-right: 10px;
  width: 20px;
  text-align: center;
}

.tool-btn:hover {
  background-color: var(--bg-tertiary);
}

.tool-btn.active, 
.tool-btn.preview-active {
  background-color: var(--accent-primary);
  color: white;
}

.tool-btn.preview-active {
  background-color: var(--success);
}

.tool-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.sidebar-footer {
  padding: 15px;
  border-top: 1px solid var(--bg-tertiary);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.dof-display {
  font-weight: 600;
  margin-bottom: 5px;
}

.sidebar-header {
  padding: 10px 15px;
}

.sidebar-header h1 {
  font-size: 1.2rem;
  margin: 0;
}

/* Reduce spacing in tool sections */
.tool-section {
  margin-bottom: 8px;
}

.tool-section h3 {
  font-size: 0.8rem;
  margin-bottom: 4px;
  padding-bottom: 3px;
}

/* Make buttons more compact */
.tool-btn {
  padding: 5px 8px;
  margin-bottom: 2px;
  min-height: 30px;
}

.tool-btn i {
  margin-right: 8px;
  width: 16px;
  font-size: 0.9rem;
}

.tool-btn span {
  font-size: 0.85rem;
}

/* Reduce padding in tools container */
.tools {
  padding: 10px;
}

/* Make footer more compact */
.sidebar-footer {
  padding: 8px 10px;
  font-size: 0.7rem;
}

/* Increase the available space for content */
.tool-section:last-child {
  margin-bottom: 5px;
}

/* Adjust sidebar scrollbar for better appearance */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--bg-tertiary);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-track {
  background-color: var(--bg-secondary);
}

/* ================ MAIN CANVAS AREA ================ */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

#canvas-container {
  flex: 1;
  background-color: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

#linkage-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#nodes-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none; /* Let events pass through to SVG */
}

.status-bar {
  height: 30px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--bg-tertiary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  z-index: 1000;
}

/* ================ NODE STYLES ================ */
.node {
  position: absolute;
  width: 30px;
  height: 30px;
  margin-left: -15px; /* Center the node */
  margin-top: -15px;  /* Center the node */
  border-radius: 50%;
  background-color: var(--accent-primary);
  border: 2px solid white;
  box-shadow: var(--box-shadow);
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  pointer-events: auto;
  transition: transform 0.1s ease;
  z-index: 10;
}

.node.ground {
  background-color: var(--danger);
}

.node.target {
  border: 3px solid var(--warning);
}

.node:hover {
  transform: scale(1.1);
}

.node.locked {
  opacity: 0.3;
  border-style: dashed;
}

/* ================ LINK/EDGE STYLES ================ */
.link {
  stroke: var(--text-primary);
  stroke-width: 3;
  transition: stroke 0.3s ease;
  cursor: pointer;
  stroke-linecap: round;
}

.link-hitbox {
  stroke: transparent;
  stroke-width: 20; /* Much wider than visible line */
  pointer-events: stroke; /* Only detect clicks on the stroke */
  cursor: pointer;
}

.link.motor {
  stroke: var(--warning);
  stroke-dasharray: 5, 3;
}

/* Hover effects for links */
.link:hover,
.link-hitbox:hover ~ .link,
g:hover > .link {
  stroke: var(--accent-primary);
}

.link.motor:hover,
.link-hitbox:hover ~ .link.motor,
g:hover > .link.motor {
  stroke: var(--accent-tertiary);
}

/* ================ SIMULATION PATH STYLES ================ */
.simulation-path {
  fill: none;
  stroke: var(--path-color);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.simulation-path.target-path {
  stroke: var(--target-path-color);
  stroke-width: 3;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 4px rgba(255, 102, 0, 0.5));
}

.simulation-path.motor-path {
  stroke: var(--motor-path-color);
  stroke-width: 3;
  stroke-dasharray: 5, 3;
}

/* Apply the same styling to temp paths for consistency */
#temp-simulation-path .simulation-path {
  /* Same settings as regular simulation paths */
  stroke: var(--path-color);
}

#temp-simulation-path .simulation-path.target-path {
  stroke: var(--target-path-color);
  stroke-width: 3;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 4px rgba(255, 102, 0, 0.5));
}

#temp-simulation-path .simulation-path.motor-path {
  stroke: var(--motor-path-color);
  stroke-width: 3;
  stroke-dasharray: 5, 3;
}

/* Path group styling */

.simulation-playing #simulation-paths {
  opacity: 0.5;
}

/* Preview path styles - now using the same class for consistency */
/* All modes now use the simulation-path class with consistent styling */

/* ================ CURSOR STYLES ================ */
body.add-ground {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="%23dc3545"><circle cx="12" cy="12" r="10" stroke="black" stroke-width="2" fill-opacity="0.5"/></svg>') 12 12, auto;
}

body.add-node {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="%230d6efd"><circle cx="12" cy="12" r="10" stroke="black" stroke-width="2" fill-opacity="0.5"/></svg>') 12 12, auto;
}

body.add-link {
  cursor: crosshair;
}

body.move-tool {
  cursor: move;
}

body.delete-tool {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="%23dc3545"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>') 12 12, auto;
}

body.select-motor, 
body.select-target {
  cursor: pointer;
}

/* ================ SIMULATION CONTROL STYLES ================ */
.simulation-controls {
  display: none;
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 10px;
  box-shadow: var(--box-shadow);
  z-index: 100;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.simulation-controls.active {
  display: flex;
  opacity: 1;
}

.simulation-controls.collapsed {
  opacity: 0;
  pointer-events: none;
}

.sim-controls-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sim-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background-color: var(--accent-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.sim-btn:hover {
  background-color: var(--accent-secondary);
  transform: scale(1.05);
}

.sim-btn.exit-btn {
  background-color: var(--danger);
}

.sim-speed-container, 
.sim-position-container {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.sim-speed-slider {
  width: 100px;
  cursor: pointer;
}

.sim-position-container {
  margin-top: 5px;
}

.sim-position-slider {
  width: 150px;
  cursor: pointer;
}

#sim-position-display {
  min-width: 40px;
  text-align: right;
}

/* Button states */
.sim-btn.paused .fa-pause:before {
  content: "\f04b"; /* Switch to play icon */
}

.sim-btn.playing .fa-play:before {
  content: "\f04c"; /* Switch to pause icon */
}

/* ================ ANIMATION STYLES ================ */
@keyframes simulationTransition {
  0% { 
    background-color: var(--bg-primary);
  }
  50% {
    background-color: var(--accent-tertiary);
    opacity: 0.2;
  }
  100% {
    background-color: var(--bg-primary);
    display: none;
  }
}

.simulation-transition {
  animation: simulationTransition 0.5s ease;
}

@keyframes pulseMarker {
  0% { r: 4; opacity: 0.7; }
  50% { r: 6; opacity: 1; }
  100% { r: 4; opacity: 0.7; }
}

.current-position-marker {
  fill: var(--accent-primary);
  stroke: white;
  stroke-width: 1;
  pointer-events: none;
  r: 3;
  animation: pulseMarker 1s infinite;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.3));
}

.current-position-marker.target {
  r: 5; /* Larger circle for target node */
  fill: var(--warning);
}

/* ================ MODAL STYLES ================ */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: var(--bg-primary);
  margin: 15% auto;
  padding: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  width: 80%;
  max-width: 500px;
}

.close-modal {
  color: var(--text-secondary);
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-btn {
  padding: 8px 16px;
  margin-left: 10px;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  background-color: var(--accent-primary);
  color: white;
  transition: var(--transition);
}

.modal-btn:hover {
  background-color: var(--accent-secondary);
}

/* ================ FEEDBACK & INDICATOR STYLES ================ */
.touch-feedback {
  position: absolute;
  background-color: var(--success);
  color: white;
  padding: 5px 10px;
  border-radius: var(--border-radius);
  z-index: 1000;
  opacity: 0;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}

.touch-feedback.visible {
  opacity: 1;
  transform: translateY(-10px);
}

.locking-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: var(--danger);
  color: white;
  padding: 5px 10px;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--box-shadow);
  z-index: 100;
}

.locking-indicator.visible {
  opacity: 1;
}

.preview-mode-indicator {
  position: absolute;
  bottom: 40px;
  right: 10px;
  background-color: var(--success);
  color: white;
  padding: 5px 10px;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--box-shadow);
  z-index: 100;
  transition: opacity 0.3s ease;
}

.preview-mode-indicator.visible {
  opacity: 1;
}

/* ================ MOBILE STYLES ================ */
.mobile-controls {
  display: none;
  position: fixed;
  bottom: 40px;
  right: 10px;
  z-index: 100;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-controls.collapsed {
  transform: translateY(300px);
  opacity: 0;
  pointer-events: none;
}

.mobile-controls-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-gap: 5px;
  background-color: rgba(var(--bg-secondary-rgb), 0.8);
  border-radius: 10px;
  padding: 5px;
  backdrop-filter: blur(5px);
  box-shadow: var(--box-shadow);
}

.mobile-btn {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-btn.active {
  background-color: var(--accent-primary);
  color: white;
}

.mobile-btn.preview-active {
  background-color: var(--success);
  color: white;
}

.mobile-controls-file {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 5px;
  background-color: rgba(var(--accent-tertiary-rgb), 0.5);
  border-radius: 10px;
  padding: 5px;
  backdrop-filter: blur(5px);
  box-shadow: var(--box-shadow);
  margin-top: 5px;
}

.mobile-file-btn {
  width: auto;
  height: 50px;
  border-radius: 8px;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-file-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.tool-name-display {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 8px 10px;
  margin-top: 5px;
  border-radius: 5px;
  text-align: center;
  font-size: 14px;
  opacity: 0.9;
  box-shadow: var(--box-shadow);
}

.mobile-toggle {
  position: fixed;
  bottom: 315px;
  right: 10px;
  z-index: 101;
  display: none;
  transition: right 0.3s ease, bottom 0.3s ease;
}

.simulation-mode .mobile-toggle {
  bottom: 235px;
  right: calc(50% - 20px);
}

.mobile-toggle.collapsed {
  bottom: 50px;
}

.mobile-toggle button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.mobile-toggle button:hover {
  background-color: var(--accent-secondary);
}

.mobile-toggle button:active {
  transform: scale(0.95);
}

.mobile-toggle button.collapsed i {
  transform: rotate(180deg);
}

/* ================ QUICK SIM STYLES ================ */
#quick-sim i {
  color: var(--warning);
}

#quick-sim.active,
.mobile-btn[data-tool="quick-sim"].active {
  background-color: var(--warning);
  color: white;
}

#quick-sim.active i,
.mobile-btn[data-tool="quick-sim"].active i {
  color: white;
}

body.quick-sim-mode #canvas-container::after {
  content: "Running quick simulation...";
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(var(--bg-secondary-rgb), 0.9);
  color: var(--text-primary);
  padding: 5px 15px;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 50;
}

body.quick-sim-mode .node {
  cursor: default;
  pointer-events: none;
}

/* Use the same path styling as simulation mode for consistency */
body.quick-sim-mode .simulation-path {
  stroke: var(--path-color);
}

body.quick-sim-mode .simulation-path.target-path {
  stroke: var(--target-path-color);
}

body.quick-sim-mode .simulation-path.motor-path {
  stroke: var(--motor-path-color);
}

body.controls-disabled .mobile-btn:not([data-tool="quick-sim"]),
body.quick-sim-mode .mobile-controls-file button,
body.controls-disabled .mobile-controls-file button {
  opacity: 0.5;
  pointer-events: none;
}

/* ================ MODE-SPECIFIC STYLES ================ */
body.simulation-mode {
  cursor: default !important;
}

body.simulation-mode .node:not(.ground) {
  cursor: default;
}

body.simulation-mode .tool-btn:not(#toggle-simulation) {
  opacity: 0.5;
  pointer-events: none;
}

body.simulation-mode .mobile-controls {
  display: none;
}

body.simulation-mode .mobile-controls-file {
  display: none;
}

/* ================ RESPONSIVE STYLES ================ */
@media (max-width: 1000px) {
  .simulation-controls {
    bottom: 50px;
    width: 90%;
    max-width: 400px;
  }
  
  .sim-controls-container {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .sim-speed-container {
    width: 100%;
    justify-content: center;
    margin-top: 10px;
  }
  
  .sim-speed-slider {
    width: 150px;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    display: none;
  }
  
  .mobile-controls, 
  .mobile-toggle {
    display: block;
  }
  
  .main-area {
    width: 100vw;
    height: calc(100vh - 30px);
  }
  
  .status-bar {
    height: 30px;
    font-size: 12px;
  }
  
  .sim-position-container {
    width: 100%;
    justify-content: center;
    margin-top: 5px;
  }
  
  .sim-position-slider {
    width: 180px;
  }
  
  .touch-feedback {
    font-size: 12px;
    padding: 4px 8px;
  }
  
  .preview-mode-indicator {
    bottom: 360px;
  }
  
  .mobile-toggle.collapsed + .preview-mode-indicator {
    bottom: 100px;
  }
  
  body.simulation-mode .mobile-sim-controls {
    display: block;
  }
}

/* Challenge Panel Styles */
.challenge-panel {
  position: fixed;
  top: 10px;
  right: 0;
  width: 320px;
  z-index: 100;
  transition: transform 0.3s ease;
}

.challenge-panel.collapsed {
  transform: translateX(100%);
}

.challenge-tab {
  position: absolute;
  left: -40px;
  top: 0;
  width: 40px;
  height: auto;
  padding: 10px 5px;
  background-color: var(--accent-secondary);
  color: white;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
}

.challenge-tab i {
  font-size: 1.2rem;
}

.challenge-tab span {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.collapse-icon {
  margin-top: 10px;
  transition: transform 0.3s ease;
}

.challenge-panel.collapsed .collapse-icon {
  transform: rotate(180deg);
}

.challenge-content {
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius) 0 0 var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: 15px;
  overflow: hidden;
  border-top-left-radius: 0;
}

.challenge-header {
  margin-bottom: 15px;
}

.challenge-header h3 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--text-primary);
}

.challenge-canvas-container {
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--border-radius);
  height: 250px;
  position: relative;
  margin-bottom: 15px;
  overflow: hidden;
}

#challenge-canvas {
  width: 100%;
  height: 100%;
}

.target-curve {
  fill: none;
  stroke: var(--target-path-color);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.solution-curve {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.user-curve {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 4, 2;
}

.challenge-canvas-label {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background-color: rgba(var(--bg-secondary-rgb), 0.7);
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  color: var(--text-primary);
}

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

.challenge-level-select {
  display: flex;
  align-items: center;
  gap: 10px;
}

.challenge-level-select label {
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.challenge-level-select select {
  flex: 1;
  padding: 5px 10px;
  border-radius: var(--border-radius);
  border: 1px solid var(--bg-tertiary);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
}

.challenge-buttons {
  display: flex;
  gap: 10px;
}

.challenge-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--border-radius);
  border: none;
  background-color: var(--accent-primary);
  color: white;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.challenge-btn:hover {
  background-color: var(--accent-secondary);
}

#clear-attempt {
  background-color: var(--text-secondary);
}

#clear-attempt:hover {
  background-color: var(--danger);
}

#show-solution {
  background-color: var(--success);
}

#show-solution:hover {
  background-color: var(--accent-tertiary);
}

.challenge-score {
  background-color: var(--bg-tertiary);
  padding: 8px 12px;
  border-radius: var(--border-radius);
  display: flex;
  justify-content: space-between;
  font-weight: 500;
}

#challenge-score-value {
  font-weight: 700;
}

/* Media queries for responsive design */
@media (max-width: 768px) {
  .challenge-panel {
      width: 280px;
  }
  
  .challenge-canvas-container {
      height: 120px;
  }
}

#quick-sim {
  order: -1; /* Force to the beginning regardless of DOM position */
  margin: 5px 0 12px 0;
  padding: 10px 12px;
  background-color: var(--warning);
  color: #000;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--border-radius);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, background-color 0.2s ease;
  min-height: 38px;
}

#quick-sim i {
  color: inherit;
  font-size: 1.2rem;
}

#quick-sim:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.mobile-btn[data-tool="quick-sim"]{
  
}

#quick-sim.active,
.mobile-btn[data-tool="quick-sim"].active {
  background-color: #ff8c00;
  color: white;
}