:root {
  --bg-color: #000000;
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.6);
  --primary: #38bdf8;
  --positive: #ff4d4d;
  --negative: #4d94ff;

  /* Liquid Glass Vars */
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow:
    inset 0 0 20px rgba(255, 255, 255, 0.05),
    inset 0 0 5px rgba(255, 255, 255, 0.1),
    0 5px 15px rgba(0, 0, 0, 0.5);

  /* Chromatic aberration shadows attempt */
  --chromatic-shadow:
    -2px 0 2px rgba(255, 0, 0, 0.2),
    2px 0 2px rgba(0, 255, 255, 0.2),
    inset 0 0 20px rgba(255, 255, 255, 0.1);

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#simulation-container {
  position: relative;
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* UI Overlay */
.ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  align-items: center;
}

/* Glass Mixin Class (Concept) */
.liquid-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: var(--chromatic-shadow);
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}

/* Shine effect */
.liquid-glass::before {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right,
      transparent,
      rgba(255, 255, 255, 0.1),
      transparent);
  transform: skewX(-25deg);
  pointer-events: none;
}

/* Header */
.header {
  pointer-events: auto;
  align-self: flex-start;
  padding: 16px 32px;
  /* Removed absolute/drag styles */
}

.header:active {
  cursor: grabbing;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, #ccc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.header p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Controls Wrapper - Restored */
.controls-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.controls {
  pointer-events: auto;
  align-self: flex-end;
  padding: 12px 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
  max-width: calc(100vw - 48px);
  flex-wrap: wrap;
  justify-content: center;
}

.controls:active {
  cursor: grabbing;
}

.toggles-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  /* Smaller switch */
  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: rgba(0, 0, 0, 0.3);
  /* Darker track */
  transition: .4s;
  border-radius: 34px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 2px;
  background: radial-gradient(circle at 30% 30%, #fff, #ccc);
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

input:checked+.slider {
  background-color: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.5);
}

input:checked+.slider:before {
  transform: translateX(16px);
  background: radial-gradient(circle at 30% 30%, #fff, #38bdf8);
  box-shadow: 0 0 10px var(--primary);
}

/* Trash Bin - Repositioned to Bottom Left */
.trash-bin {
  pointer-events: auto;
  position: absolute;
  bottom: 24px;
  left: 24px;
  /* CHANGED FROM right: 24px */
  width: 80px;
  height: 80px;

  /* Liquid Glass Style */
  background: rgba(255, 50, 50, 0.05);
  /* Slight red tint */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 0 20px rgba(239, 68, 68, 0.1),
    0 4px 15px rgba(0, 0, 0, 0.3);

  border-radius: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 2rem;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 50;
  flex-direction: column;
}

.trash-hint {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%) translateX(10px);
  /* Right side */
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.trash-bin:hover .trash-hint,
.trash-bin.drag-over .trash-hint {
  opacity: 1;
  transform: translateY(-50%) translateX(20px);
}

.trash-bin.drag-over {
  background: rgba(239, 68, 68, 0.4);
  border-color: #ffaaaa;
  transform: scale(1.15) rotate(-5deg);
  box-shadow:
    0 0 30px rgba(239, 68, 68, 0.6),
    inset 0 0 20px rgba(255, 255, 255, 0.5);
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Number Input */
input[type="number"] {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 6px 8px;
  border-radius: 8px;
  min-width: 40px;
  max-width: 80px;
  text-align: right;
  font-family: 'Inter', monospace;
  font-size: 0.95rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Hide spin buttons */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* Buttons */
.btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 12px 24px;
  border-radius: 14px;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(56, 189, 248, 0.1));
  border-color: rgba(56, 189, 248, 0.3);
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.4), rgba(56, 189, 248, 0.2));
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.1));
  color: #ffcccc;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(239, 68, 68, 0.2));
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.1));
  color: #ccffcc;
  border-color: rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.4), rgba(34, 197, 94, 0.2));
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.2), rgba(234, 179, 8, 0.1));
  color: #fff8cc;
  border-color: rgba(234, 179, 8, 0.3);
}

.btn-warning:hover {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.4), rgba(234, 179, 8, 0.2));
  box-shadow: 0 0 20px rgba(234, 179, 8, 0.4);
}

.divider {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.2);
}

/* Charge info panel */
.charge-panel {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  width: 320px;
  display: none;
  flex-direction: column;
  gap: 20px;
  animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 24px;
  cursor: grab;
  z-index: 100;
}

.charge-panel:active {
  cursor: grabbing;
}

.charge-panel.active {
  display: flex;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translate(30px, -50%) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translate(0, -50%) scale(1);
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
  margin-bottom: 4px;
}

.panel-title {
  font-weight: 600;
  font-size: 1.1rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #fff;
  text-shadow: 0 0 10px #fff;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 0, 0, 0.3);
  height: 8px;
  border-radius: 4px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: radial-gradient(circle at 30% 30%, #fff, #ccc);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px #fff;
}

.hint {
  pointer-events: none;
  position: absolute;
  bottom: 120px;
  width: 100%;
  text-align: center;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.9rem;
  opacity: 0;
  animation: fadeIn 1s 1s forwards;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}