:root {
  --primary-text: #FFFFFF;
  --highlight-blue: #4169FF;
  --background: #1A1A1A;
  --secondary-text: #A0A0A0;
  --shadow: rgba(0, 0, 0, 0.2);
  --hex-pattern: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M50 0 L61.8 25 L88.4 25 L69.3 40.8 L88.4 56.7 L61.8 56.7 L50 81.7 L38.2 56.7 L11.6 56.7 L30.7 40.8 L11.6 25 L38.2 25 Z" fill="rgba(255,255,255,0.05)"/></svg>');
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');

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

body {
  font-family: 'Inter', 'Orbitron', sans-serif;
  background-color: var(--background);
  color: var(--primary-text);
  line-height: 1.4;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  padding-top: 80px;
  width: 100vw;
  height: 100vh;
  background-image: var(--hex-pattern);
  background-repeat: repeat;
}

.controls-panel {
  display: flex;
  align-items: center;
  background: linear-gradient(90deg, #1A1A1A, #2D2D2D);
  padding: 0.75rem 1.5rem;
  gap: 1rem;
  width: 100%;
  height: 70px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  box-shadow: 0 2px 10px var(--shadow);
}

h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-right: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.control-btn {
  padding: 0.6rem 1rem;
  background: var(--highlight-blue);
  color: var(--primary-text);
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  box-shadow: 0 2px 5px var(--shadow);
}

.control-btn:hover {
  background-color: #5A6EFF;
  transform: translateY(-2px);
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.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: #4A4A4A;
  transition: .4s;
  border-radius: 20px;
  box-shadow: inset 0 2px 4px var(--shadow);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #FFFFFF;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 5px var(--shadow);
}

input:checked + .slider {
  background-color: var(--highlight-blue);
}

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

.toggle-label {
  font-size: 0.9rem;
  color: var(--secondary-text);
  font-weight: 600;
}

.mode-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-dropdown {
  padding: 0.4rem 0.6rem;
  background: #3A3A3A;
  color: var(--primary-text);
  border: 1px solid #555;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  outline: none;
  transition: border-color 0.3s ease;
}

.mode-dropdown:hover,
.mode-dropdown:focus {
  border-color: var(--highlight-blue);
}

.mode-dropdown option {
  background: #2D2D2D;
  color: var(--primary-text);
}

.tray-stack-badge {
  position: absolute;
  background: #1A1A1A;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid #555;
  pointer-events: none;
  z-index: 50;
  line-height: 1.2;
  white-space: nowrap;
  width: auto;
}

.tray-image {
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

#backgroundUpload {
  display: none;
}

.custom-file-upload {
  display: inline-block;
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
  background: var(--highlight-blue);
  color: var(--primary-text);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  box-shadow: 0 2px 5px var(--shadow);
  text-align: center;
}

.custom-file-upload:hover {
  background-color: #5A6EFF;
  transform: translateY(-2px);
}

body:after {
  content: '';
  position: absolute;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--background);
  z-index: -2;
}

.background-image {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translate(-50%, 0);
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
  z-index: -1;
  pointer-events: none;
}

.draggable {
  position: absolute;
  cursor: move;
  z-index: 1;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transition: opacity 0.3s ease, transform 0.1s ease;
  will-change: transform;
  backface-visibility: hidden;
}

.help-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.help-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #2D2D2D;
  color: var(--primary-text);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  font-family: 'Inter', sans-serif;
  animation: fadeIn 0.3s ease;
}

.help-popup h3 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--highlight-blue);
}

.help-popup ul {
  list-style: none;
  padding: 0;
}

.help-popup li {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
  position: relative;
  padding-left: 1.5rem;
}

.help-popup li:before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--highlight-blue);
  font-size: 1.2rem;
}

.help-popup .close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--primary-text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.3s ease;
}

.help-popup .close-btn:hover {
  color: var(--highlight-blue);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -60%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

@media only screen and (max-width: 768px) {
  .controls-container {
    display: none;
  }

  body {
    padding-top: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .mobile-message {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: var(--primary-text);
    text-align: center;
    padding: 1rem;
    z-index: 200;
    font-size: 1rem;
    font-weight: 600;
    justify-content: center;
    align-items: center;
  }

  .draggable.bot-image {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.1s ease;
    touch-action: none;
  }

  body:after {
    top: 0;
  }
}
