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

body {
  min-height: 100vh;
  width: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background-color: #F4F5F6;
}

.container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
  background-color: #F4F5F6;
}

.if-vid {
  flex: 1;
  padding: 20px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.p-head {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 20px;
  font-size: 18px;
  color: #333;
  align-self: flex-start;
}

.interfacing {
  position: relative;
  display: block;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.interfacing img {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 20px;
}

#circuit-container {
  width: 100%;
  max-width: 1000px;
  margin-top: 20px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.arduino-svg {
  width: 100%;
  height: auto;
  display: block;
}

.lcd-overlay {
  position: absolute;
  top: 312px;
  left: 462px;
  width: 196px;
  height: 76px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-family: 'Courier New', Courier, monospace;
  pointer-events: none;
  z-index: 5;
}

.lcd-text {
  font-size: 14px;
  font-weight: bold;
  color: #a0aec0;
  margin: 2px 0;
  transition: color 0.3s;
}

.controls-overlay {
  margin-top: 30px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80px;
}

.smoke-btn {
  padding: 12px 24px;
  background: #4a5568;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.smoke-btn:hover {
  background: #2d3748;
  transform: translateY(-2px);
}

.slider-wrapper {
  background: white;
  padding: 15px 25px;
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 15px;
  width: 90%;
  max-width: 500px;
}

.slider-label {
  font-size: 11px;
  font-weight: 700;
  color: #4a5568;
  text-transform: uppercase;
  white-space: nowrap;
  width: 110px;
  /* Fixed width */
  flex-shrink: 0;
}

#pollutionSlider {
  flex: 1;
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 10px;
  outline: none;
  margin: 0 15px;
  cursor: pointer;
}

/* Webkit (Chrome, Edge, Safari) */
#pollutionSlider::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  cursor: pointer;
  background: #e2e8f0;
  border-radius: 10px;
}

#pollutionSlider::-webkit-slider-thumb {
  height: 24px;
  width: 24px;
  border-radius: 50%;
  background: #3182ce;
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -8px;
  /* Centering adjustment: (8/2 - 24/2) = -8 */
  border: 4px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

#pollutionSlider:active::-webkit-slider-thumb {
  transform: scale(0.9);
}

/* Firefox */
#pollutionSlider::-moz-range-track {
  width: 100%;
  height: 8px;
  cursor: pointer;
  background: #e2e8f0;
  border-radius: 10px;
}

#pollutionSlider::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: #3182ce;
  cursor: pointer;
  border: 4px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-value {
  font-weight: 800;
  color: #3182ce;
  width: 50px;
  text-align: center;
  flex-shrink: 0;
  font-size: 14px;
}

.buzzer-warning {
  font-size: 11px;
  font-weight: 800;
  color: #718096;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  background: #edf2f7;
  white-space: nowrap;
  width: 120px;
  /* Fixed width */
  text-align: center;
  flex-shrink: 0;
  transition: background 0.3s, color 0.3s;
}

.buzzer-warning.danger {
  background: #fff5f5;
  color: #e53e3e;
  box-shadow: 0 0 0 2px rgba(229, 62, 62, 0.1);
  animation: pulse-border 0.8s infinite;
}

@keyframes pulse-border {
  0% {
    box-shadow: 0 0 0 0px rgba(229, 62, 62, 0.4);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(229, 62, 62, 0);
  }

  100% {
    box-shadow: 0 0 0 0px rgba(229, 62, 62, 0);
  }
}

.right-panel {
  width: 650px;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
  border-left: 1px solid #e0e0e0;
  overflow: hidden;
}

.instruction-box {
  flex: 0 0 50%;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #e0e0e0;
  overflow: hidden;
}

.box-title {
  padding: 15px 20px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.instruction-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 14px;
  line-height: 1.6;
  color: #555;
}

.instruction-content::-webkit-scrollbar {
  width: 8px;
}

.instruction-content::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.instruction-content::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.instruction-content::-webkit-scrollbar-thumb:hover {
  background: #555;
}

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

.instruction-section:last-child {
  margin-bottom: 0;
}

.instruction-section h4 {
  color: #2c3e50;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
}

.instruction-section p {
  margin-bottom: 10px;
  color: #555;
}

.instruction-section ol,
.instruction-section ul {
  margin-left: 20px;
  margin-bottom: 10px;
}

.instruction-section li {
  margin-bottom: 8px;
  line-height: 1.5;
}

.instruction-section strong {
  color: #333;
  font-weight: 600;
}

.code-box {
  flex: 0 0 50%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.code-box-header {
  padding: 15px 20px;
  background-color: #2d2d2d;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #3d3d3d;
}

.code-box-header .box-title {
  color: #ffffff;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 14px;
}

.code-actions {
  display: flex;
  gap: 10px;
}

.control-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.start-btn {
  background-color: #4caf50;
  color: white;
}

.start-btn:hover {
  background-color: #45a049;
}

.stop-btn {
  background-color: #f44336;
  color: white;
}

.stop-btn:hover {
  background-color: #da190b;
}

.play-icon {
  font-size: 10px;
}

.code-btn {
  padding: 5px 12px;
  background-color: #4a4a4a;
  color: #ffffff;
  border: none;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.code-btn:hover {
  background-color: #5a5a5a;
}

.code-content {
  flex: 1;
  overflow: hidden;
  background-color: #272822;
}

.code-content .CodeMirror {
  width: 100%;
  height: 100%;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
}

.code-content .CodeMirror-scroll {
  overflow-y: auto !important;
  overflow-x: auto !important;
  min-height: 100%;
}

.code-content .CodeMirror-hscrollbar {
  height: 12px !important;
}

.code-content .CodeMirror-vscrollbar {
  width: 12px !important;
}

.code-content .CodeMirror-scrollbar-filler {
  background-color: #272822;
}

.code-content .CodeMirror-hscrollbar::-webkit-scrollbar {
  height: 12px;
}

.code-content .CodeMirror-hscrollbar::-webkit-scrollbar-track {
  background: #1e1e1e;
}

.code-content .CodeMirror-hscrollbar::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 6px;
}

.code-content .CodeMirror-hscrollbar::-webkit-scrollbar-thumb:hover {
  background: #777;
}

.code-content .CodeMirror-vscrollbar::-webkit-scrollbar {
  width: 12px;
}

.code-content .CodeMirror-vscrollbar::-webkit-scrollbar-track {
  background: #1e1e1e;
}

.code-content .CodeMirror-vscrollbar::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 6px;
}

.code-content .CodeMirror-vscrollbar::-webkit-scrollbar-thumb:hover {
  background: #777;
}

#arduinoCode {
  display: none;
}

@media screen and (max-width: 1024px) {
  .container {
    flex-direction: column;
  }

  .if-vid {
    height: 50%;
    padding: 15px;
  }

  .p-head {
    margin-left: 0;
    text-align: center;
    font-size: 16px;
  }

  .right-panel {
    width: 100%;
    height: 50%;
  }

  .instruction-box,
  .code-box {
    flex: 0 0 50%;
  }

  .code-box-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  .code-box-header .box-title {
    flex: 1 1 100%;
    margin-bottom: 5px;
  }

  #smoke {
    font-size: 12px;
    padding: 10px 20px;
  }

  #sliderComment {
    font-size: 11px;
    bottom: 70px;
  }
}

@media screen and (max-width: 768px) {
  .if-vid {
    padding: 10px;
    height: 45%;
  }

  .p-head {
    font-size: 14px;
    margin-left: 0;
    margin-bottom: 10px;
  }

  .interfacing {
    max-width: 100%;
  }

  .right-panel {
    width: 100%;
    height: 55%;
  }

  .instruction-box {
    flex: 0 0 45%;
  }

  .code-box {
    flex: 0 0 55%;
  }

  .box-title {
    padding: 12px 15px;
    font-size: 14px;
  }

  .instruction-content {
    padding: 15px;
    font-size: 13px;
  }

  .control-btn {
    padding: 8px 12px;
    font-size: 11px;
    gap: 4px;
  }

  .code-box-header {
    padding: 10px 15px;
    flex-direction: column;
    align-items: flex-start;
  }

  .code-box-header .box-title {
    margin-bottom: 8px;
  }

  .code-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .code-content .CodeMirror {
    font-size: 11px;
  }

  #smoke {
    font-size: 11px;
    padding: 8px 16px;
  }

  #sliderComment {
    font-size: 10px;
    padding: 6px 12px;
    bottom: 65px;
  }

  #imageSlider {
    bottom: 30px;
    width: 85%;
  }
}

@media screen and (max-width: 480px) {
  .if-vid {
    padding: 8px;
    height: 40%;
  }

  .p-head {
    font-size: 12px;
    margin-bottom: 8px;
  }

  .right-panel {
    height: 60%;
  }

  .instruction-box {
    flex: 0 0 40%;
  }

  .code-box {
    flex: 0 0 60%;
  }

  .box-title {
    padding: 10px 12px;
    font-size: 13px;
  }

  .instruction-content {
    padding: 10px;
    font-size: 12px;
  }

  .instruction-section h4 {
    font-size: 13px;
  }

  .instruction-section li {
    margin-bottom: 6px;
  }

  .control-btn {
    padding: 8px 10px;
    font-size: 10px;
    gap: 3px;
  }

  .play-icon {
    font-size: 9px;
  }

  .code-box-header {
    padding: 8px 12px;
  }

  .code-box-header .box-title {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .code-content .CodeMirror {
    font-size: 10px;
  }

  #smoke {
    font-size: 10px;
    padding: 6px 12px;
  }

  #sliderComment {
    font-size: 9px;
    padding: 5px 10px;
    bottom: 55px;
  }

  #imageSlider {
    bottom: 25px;
    width: 90%;
  }
}