/* import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;800&family=Inter:wght@300;400;500;700&display=swap');

:root {
  /* HSL Color System */
  --bg-primary: #e24a18; /* Vibrant red-orange background */
  --bg-secondary: #d64413; 
  --bg-tertiary: #bf360c; 
  
  /* LOFI Control Theme Colors (Screenshot Orange) */
  --cardboard-light: #e24a18; 
  --cardboard-medium: #ffffff; /* Secondary is white */
  --cardboard-dark: #f8fafc; 
  --cardboard-glow: rgba(255, 255, 255, 0.2);
  
  /* Electronic Accents */
  --neon-cyan: #ffffff; /* White is the main accent on orange background */
  --neon-cyan-glow: rgba(255, 255, 255, 0.25);
  --neon-orange: #ffffff;
  --neon-orange-glow: rgba(255, 255, 255, 0.3);
  --neon-green: #2ecc71;
  --neon-red: #ffffff;
  
  /* UI Constants */
  --font-header: 'Montserrat', sans-serif;
  --font-body: 'Inter', sans-serif;
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  --border-radius-round: 50%;
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --glass-bg: rgba(255, 255, 255, 0.08); /* Clean white glass on orange background */
  --glass-border: rgba(255, 255, 255, 0.25);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: #ffffff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Subtle white overlay gradients to keep the background clean and vibrant orange */
body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.04) 0%, transparent 40%);
  z-index: -1;
  pointer-events: none;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-header);
  font-weight: 800;
  letter-spacing: -0.02em;
}

a {
  color: var(--cardboard-light);
  text-decoration: none;
  transition: var(--transition-smooth);
}

a:hover {
  color: var(--neon-cyan);
}

/* Header & Branding */
header {
  background-color: #e24a18;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #ffffff;
  border-radius: var(--border-radius-round);
  width: 44px;
  height: 44px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.brand-logo {
  max-height: 100%;
  max-width: 100%;
  height: auto;
  width: auto;
  object-fit: contain;
}

.brand-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.brand-tagline {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand-meta {
  display: flex;
  flex-direction: column;
}

/* Bluetooth Connection Badge & Button */
.connection-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: var(--border-radius-sm);
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: var(--transition-smooth);
}

.status-badge.connected {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.status-badge.disconnected {
  color: rgba(255, 255, 255, 0.8);
  background-color: rgba(0, 0, 0, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.connected .status-dot {
  background-color: #2ecc71;
  box-shadow: 0 0 8px #2ecc71;
  animation: pulse-connected 2s infinite;
}

.disconnected .status-dot {
  background-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.btn {
  font-family: var(--font-header);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.btn-primary {
  background: #ffffff;
  color: var(--cardboard-light);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
  background: #f8fafc;
  color: #d64413;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

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

.btn-danger {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.btn-danger:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* App Main Layout Grid */
.app-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
  }
}

/* Control Workspace Panel */
.panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.live-monitor-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: auto;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: #94a3b8;
  border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  margin-bottom: -1.5rem;
  text-transform: uppercase;
}

.monitor-title {
  font-weight: 700;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
}

.monitor-value {
  color: var(--neon-cyan);
  font-weight: 700;
  text-shadow: 0 0 5px rgba(0, 240, 255, 0.3);
}

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

.panel-title {
  font-size: 1.1rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title svg {
  color: var(--cardboard-light);
}

.tabs-container {
  display: flex;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--border-radius-md);
  padding: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--font-header);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.tab-btn.active {
  color: var(--cardboard-light);
  background: #ffffff;
  border: none;
}

.tab-btn.active svg {
  color: var(--cardboard-light);
  filter: none;
}

/* Views (Content Cards) */
.view-content {
  flex: 1;
  display: none;
  align-items: center;
  justify-content: center;
  position: relative;
}

.view-content.active {
  display: flex;
  animation: fade-in 0.3s ease-out;
}

/* 1. D-PAD View Layout */
.dpad-layout {
  display: grid;
  grid-template-columns: repeat(3, 90px);
  grid-template-rows: repeat(3, 90px);
  gap: 15px;
  justify-content: center;
  align-content: center;
  user-select: none;
}

.dpad-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.dpad-btn svg {
  width: 48px;
  height: 48px;
  transition: var(--transition-smooth);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.dpad-btn:hover {
  color: var(--cardboard-light);
  filter: drop-shadow(0 0 8px var(--cardboard-glow));
}

.dpad-btn.active, .dpad-btn:active {
  color: var(--cardboard-light);
  transform: scale(0.9);
  filter: drop-shadow(0 0 15px var(--cardboard-glow));
}

/* Positions */
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-stop {
  grid-column: 2;
  grid-row: 2;
  border-radius: 50%;
  background: #ffffff;
  color: var(--cardboard-light);
  border: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}
.dpad-stop:hover {
  background: #f8fafc;
  box-shadow: 0 6px 20px rgba(226, 74, 24, 0.3);
  transform: scale(1.05);
}
.dpad-stop.active, .dpad-stop:active {
  background: var(--cardboard-light);
  color: #ffffff;
  transform: scale(0.95);
  box-shadow: 0 0 25px rgba(226, 74, 24, 0.5);
}
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* Keyboard Indicator Tip */
.keyboard-tip {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.3rem 0.8rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-family: monospace;
  color: #cbd5e1;
  font-size: 0.7rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

/* 2. ANALOG JOYSTICK VIEW */
.joystick-outer {
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(18, 19, 26, 0.8) 0%, rgba(10, 11, 14, 0.95) 100%);
  border: 3px solid rgba(224, 180, 117, 0.25);
  border-radius: var(--border-radius-round);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.5),
    inset 0 0 20px rgba(224, 180, 117, 0.05);
  touch-action: none; /* Prevents scroll on mobile */
  transition: border-color 0.3s;
}

.joystick-outer::before {
  /* Crosshair axis markers */
  content: "";
  position: absolute;
  width: 100%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(224, 180, 117, 0.1) 50%, transparent);
}

.joystick-outer::after {
  content: "";
  position: absolute;
  height: 100%;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(224, 180, 117, 0.1) 50%, transparent);
}

.joystick-outer.active-drag {
  border-color: var(--neon-cyan);
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.5),
    0 0 20px var(--neon-cyan-glow),
    inset 0 0 20px rgba(0, 240, 255, 0.05);
}

.joystick-handle {
  width: 76px;
  height: 76px;
  background: #ffffff;
  border: none;
  border-radius: var(--border-radius-round);
  position: absolute;
  z-index: 5;
  cursor: grab;
  box-shadow: 
    0 8px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.05s ease-out;
}

.joystick-outer.active-drag .joystick-handle {
  background: #ffffff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
  cursor: grabbing;
}

.joystick-handle-inner {
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-round);
  background: rgba(226, 74, 24, 0.08);
  border: 2px solid rgba(226, 74, 24, 0.35);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.joystick-values {
  margin-top: 1.5rem;
  font-family: monospace;
  font-size: 0.9rem;
  color: #94a3b8;
  display: flex;
  gap: 1.5rem;
}

.joystick-val-box {
  background: rgba(0, 0, 0, 0.2);
  padding: 0.4rem 0.8rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.joystick-val-box span {
  font-weight: bold;
  color: var(--neon-cyan);
}

/* 3. BUTTONS & SLIDERS VIEW */
.mixed-controls {
  width: 100%;
  max-width: 580px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 1rem;
}

@media (max-width: 600px) {
  .mixed-controls {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.controls-group {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.controls-group h3 {
  font-size: 0.95rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.action-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.action-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  color: var(--cardboard-light);
  font-family: var(--font-header);
  font-weight: 800;
  font-size: 2.2rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.action-btn span {
  display: none; /* Hide subtext to match pure circles in screenshot */
}

.action-btn:hover {
  background: #f8fafc;
  box-shadow: 0 8px 20px rgba(226, 74, 24, 0.2);
  transform: translateY(-3px);
}

.action-btn:active, .action-btn.active {
  background: var(--cardboard-light);
  color: #ffffff;
  transform: translateY(1px);
  box-shadow: 0 0 20px var(--neon-orange-glow);
}

.action-btn:active span, .action-btn.active span {
  color: #ffffff;
}

/* Slider Design styling */
.slider-container {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 1rem;
  border-radius: var(--border-radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
}

.slider-label span:last-child {
  font-family: monospace;
  color: var(--neon-orange);
}

.custom-range {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--cardboard-light);
  border-radius: 2px;
  outline: none;
  margin: 15px 0;
}

.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s;
}

.custom-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* 4. ACCELEROMETER / TILT VIEW */
.tilt-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 400px;
}

.tilt-indicator-box {
  width: 100%;
  aspect-ratio: 16/9;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-md);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tilt-plane {
  width: 120px;
  height: 120px;
  border: 2px dashed rgba(224, 180, 117, 0.3);
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease-out;
  position: relative;
}

.tilt-plane::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--neon-orange);
  box-shadow: 0 0 10px var(--neon-orange-glow);
}

.tilt-grid-line {
  position: absolute;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.03);
}

.tilt-grid-line.vertical {
  transform: rotate(90deg);
}

.tilt-btn-active {
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--neon-cyan);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-md);
  font-family: var(--font-header);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.tilt-btn-active:hover {
  background: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.15);
}

.tilt-btn-active.enabled {
  background: var(--neon-cyan);
  color: #000000;
  font-weight: 700;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.3);
}

/* Sidebar Panels (Packet Log & Help info) */
.sidebar-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.log-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  height: 320px;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-title {
  font-size: 0.9rem;
  font-family: var(--font-header);
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.log-title svg {
  color: var(--neon-cyan);
}

.log-clear-btn {
  background: transparent;
  border: none;
  color: #475569;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.log-clear-btn:hover {
  color: #ef4444;
}

.log-list {
  flex: 1;
  overflow-y: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--border-radius-sm);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.log-entry {
  color: #ffffff;
  word-break: break-all;
  display: flex;
  gap: 0.4rem;
}

.log-time {
  color: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.log-direction {
  color: #ffffff;
  font-weight: bold;
  flex-shrink: 0;
}

.log-data {
  color: #ffffff;
}

.log-list::-webkit-scrollbar, .help-body::-webkit-scrollbar {
  width: 6px;
}

.log-list::-webkit-scrollbar-thumb, .help-body::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.log-list::-webkit-scrollbar-track, .help-body::-webkit-scrollbar-track {
  background: transparent;
}

/* Help Info / Program Code Panel */
.help-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 250px;
}

.help-header {
  font-size: 0.9rem;
  font-family: var(--font-header);
  font-weight: 700;
  text-transform: uppercase;
  color: #ffffff;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.help-header svg {
  color: #ffffff;
}

.help-body {
  flex: 1;
  overflow-y: auto;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.help-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.help-section h4 {
  color: #ffffff;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.help-section p {
  line-height: 1.4;
  font-size: 0.8rem;
}

.code-block-container {
  position: relative;
  margin-top: 0.5rem;
}

.code-block {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.6rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: #ffeb3b;
  overflow-x: auto;
  white-space: pre;
}

.code-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-size: 0.65rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.code-copy-btn:hover {
  background: rgba(224, 180, 117, 0.15);
  color: #ffffff;
  border-color: var(--cardboard-light);
}

/* Footer Section */
footer {
  margin-top: auto;
  padding: 1.5rem 2rem;
  text-align: center;
  border-top: 1px solid var(--glass-border);
  background: rgba(10, 11, 14, 0.9);
  color: #64748b;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

/* Animations */
@keyframes pulse-connected {
  0% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(0, 240, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
}

@keyframes fade-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* Modal Connection Dialog */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
  animation: fade-in 0.25s ease-out;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  max-width: 480px;
  width: 90%;
  padding: 2rem;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-title {
  font-size: 1.25rem;
  color: #ffffff;
  margin-bottom: 0.75rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.modal-close:hover {
  color: #ffffff;
}

.modal-body {
  font-size: 0.85rem;
  color: #94a3b8;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-body ol {
  padding-left: 1.25rem;
}

.modal-body li {
  margin-bottom: 0.5rem;
}

/* Touch orientation optimizations */
@media (max-height: 500px) and (orientation: landscape) {
  header {
    padding: 0.5rem 1rem;
  }
  .brand-tagline {
    display: none;
  }
  .app-container {
    grid-template-columns: 1fr;
    padding: 0.5rem;
    gap: 0.5rem;
  }
  .panel {
    min-height: auto;
    height: calc(100vh - 70px);
    padding: 0.75rem;
  }
  .panel-header {
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
  }
  .view-content {
    justify-content: center;
  }
  .dpad-layout {
    grid-template-columns: repeat(3, 70px);
    grid-template-rows: repeat(3, 70px);
    gap: 8px;
  }
  .dpad-btn svg {
    width: 24px;
    height: 24px;
  }
  .joystick-outer {
    width: 150px;
    height: 150px;
  }
  .joystick-handle {
    width: 54px;
    height: 54px;
  }
  .sidebar-container {
    display: none; /* Hide debug/help logs in tight landscape screens */
  }
  footer {
    display: none;
  }
}

/* Warning Banner */
.warning-banner {
  background-color: #fff2cc;
  border-bottom: 2px solid #f1c40f;
  color: #7f6000;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  z-index: 1001;
  font-family: var(--font-body);
}

.warning-icon {
  font-size: 1.25rem;
}

.warning-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.warning-text strong {
  font-weight: 700;
  color: #d35400;
}

/* Hide Sidebar Console & Enable Bottom Activity Monitor Ticker on Mobile */
@media (max-width: 1024px) {
  /* Hide sidebar completely on mobile/tablet to avoid vertical clutter */
  .sidebar-container {
    display: none !important;
  }

  /* Remove 520px min-height constraints on mobile to keep controls within viewport */
  .panel {
    min-height: auto;
    padding: 1rem;
  }

  .app-container {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  /* Prevent controls from blowing out vertically */
  .view-content {
    min-height: auto;
    padding: 1rem 0;
  }

  /* Adjust negative margins of live monitor bar to match 1rem mobile panel padding */
  .live-monitor-bar {
    margin-left: -1rem;
    margin-right: -1rem;
    margin-bottom: -1rem;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
  }
}


/* Mobile Responsive Overrides for Screens under 768px (Portrait mobile/tab) */
@media (max-width: 768px) {
  /* Header Redesign */
  header {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    gap: 0.75rem;
  }
  
  .brand-container {
    justify-content: center; /* Center the logo and brand on mobile */
    text-align: center;
  }
  
  .brand-tagline {
    display: none; /* Hide tagline for vertical space */
  }
  
  .connection-area {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    width: 100%;
  }
  
  .connection-area .btn, 
  .connection-area .status-badge {
    font-size: 0.75rem;
    padding: 0.5rem 0.25rem;
    justify-content: center;
    width: 100%;
    margin: 0;
    white-space: nowrap;
  }
  
  #connect-btn {
    grid-column: span 2; /* Prominent Pair button spans full row */
  }

  /* Control Panel Header */
  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
  }
  
  .panel-title {
    justify-content: center; /* Center "Control Board" title */
    font-size: 1rem;
  }
  
  .tabs-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 tabs, equal width */
    width: 100%;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius-md);
    padding: 3px;
    gap: 2px;
    border: 1px solid rgba(255, 255, 255, 0.05);
  }
  
  .tab-btn {
    font-size: 0.7rem;
    padding: 0.5rem 0.1rem;
    justify-content: center;
    border-radius: calc(var(--border-radius-md) - 2px);
    width: 100%;
    margin: 0;
    gap: 2px;
    flex-direction: column; /* Stack SVG and Label vertically to fit */
  }
  
  .tab-btn svg {
    width: 12px;
    height: 12px;
  }
  
  /* Save vertical height inside workspace */
  .dpad-layout {
    margin: 1rem auto;
  }
  
  .keyboard-tip {
    display: none; /* Hide keyboard labels on mobile touch screen */
  }
}
